Search code examples
rubyrvmchef-infraberkshelf

switching ruby with rvm breaks chef 11.4.4 knife command


I have chef 11.4.4 which has ruby 1.9.1 installed. I want to install berkshelf but it requires ruby 1.9.2 or later. I installed ruby 2.0.0-p247 (latest stable) with rvm. When i run a knife command I get ...

# knife help 
/opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find chef (>= 0) amongst [rake-10.1.0, rvm-1.11.3.8] (Gem::LoadError)
from /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /opt/chef/embedded/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/bin/knife:22:in `<main>'

If I switch it back to the system version, which is the version of ruby embedded with chef, it works again.

# rvm use system
Now using system ruby.
# knife help
Usage: knife SUBCOMMAND (options)
.
.
.

I've googled around for ways to upgrade ruby to 2.0.0x for chef but no luck. I like the ability to switch ruby versions so easily. It would be great if chef could do the same but just getting it to work with the latest stable or even 1.9.2 version of ruby would be great. Thanks!


Solution

  • It's neither Chef 11.4.4 nor Ruby 2.0.0's fault, but rubygems 2.0.x;-)

    See => CHEF-3933

    Workaround is to install an older version of rubygemsTry to install an old version of rubygems, for example 1.8.25 gem update --system 1.8.25 or switch to 1.9.3-p448 for the time being.

    I solved the chef-solo run problem anyway.

    More info: