[chef] Re: chef_gem vs. gem_package


Chronological Thread 
  • From: Bryan McLellan < >
  • To: " " < >
  • Subject: [chef] Re: chef_gem vs. gem_package
  • Date: Tue, 6 Aug 2013 10:56:35 -0400

On Mon, Aug 5, 2013 at 8:31 AM, Sam Darwin 
< >
 wrote:
> gem_package will fall-back to chef_gem behavior if ruby isn't on the system.
> have you seen this?  Am I imagining it?     The problem is that you don't 
> get
> consistent results from a recipe.   If one machine has a system ruby 1.8,
> another machine has chef-client (with ruby 1.9) and no system ruby, very
> different things can happen with the same recipe.     Should the meaning of
> chef_gem vs. gem_package , and the differences between them,  be more 
> enforced?

chef_gem is for installing Gems you want to use in your Chef recipes.
It will be installed to the Ruby that Chef is running under early in
the Chef run so you can use that gem immediately.

gem_package is for installing Rubygems that you want to use on your
system (e.g. Rails). It will look for a gem command in your path and
fail if it can't find one. If the Ruby that you run Chef under is the
same as the first one in your path, then gem_package and chef_gem
install the gem to the same place, but chef_gem does so earlier in a
Chef run (and runs Gem.clear_paths to ensure the gem is loaded to the
current Ruby).

As long as you're using the Omnibus installs, gem_package should fail
if you haven't installed Ruby on your system.

Bryan


 ~]$ pkg_info | grep ruby

 ~]$ pkg_info | grep ohai

 ~]$ cat foo.rb
gem_package "ohai"

 ~]$ sudo chef-apply foo.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * gem_package[ohai] action install
================================================================================
Error executing action `install` on resource 'gem_package[ohai]'
================================================================================

Chef::Exceptions::FileNotFound
------------------------------
Unable to find 'gem' binary in path:
/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/vagrant/bin

[snip]



Archive powered by MHonArc 2.6.16.

§