Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 666
Ryan B. Avatar asked Dec 01 '22 20:12

Ryan B.


1 Answers

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
like image 109
mpapis Avatar answered Dec 06 '22 11:12

mpapis