Question

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!

Was it helpful?

Solution 2

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:

OTHER TIPS

You need to use a ruby with rvm:

rvm use 2.0.0-p247

this will set up environment to use that ruby, you can set it default for new shells/sessions with:

rvm alias create default 2.0.0 #OR:
rvm use 2.0.0 --default

It is also required to install the gems again as you switch to new ruby:

gem install chef

rvm reset should fix the problem.

When you switch ruby version with rvm use you need to rvm reset again though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top