Switch ruby ​​with rvm breaks chef 11.4.4 knife command

I have a chef 11.4.4 with ruby ​​1.9.1. I want to install berkshelf, but that requires ruby ​​1.9.2 or later. I installed ruby ​​2.0.0-p247 (latest stable) with rvm. When I run the 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 bring it back to the system version, which is the ruby ​​version built in with the chef, it works again.

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

I was looking for ways to upgrade ruby ​​to 2.0.0x for the chef, but no luck. I like to switch easily to ruby ​​versions. It would be great if the chef could do the same, but just make it work with the latest stable version or even version 1.9.2 would be great. Thanks!

+4
source share
3 answers

This is neither chef 11.4.4 nor Ruby 2.0.0, but rubygems 2.0.x; -)

See => CHEF-3933

Workaround is to install an older version of rubygems Try installing an older version of rubygems, for example 1.8.25 gem update --system 1.8.25 or switch to 1.9.3-p448 now.

In any case, I solved the problem of running chef-solo .

Additional Information:

+5
source

You need to use ruby ​​with rvm:

 rvm use 2.0.0-p247 

this will create an environment for using this ruby, you can set it as default for new shells / sessions with:

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

You also need to set the gems again when switching to a new ruby:

 gem install chef 
+11
source

rvm reset should fix the problem.

When you switch the ruby ​​version with rvm use , you need another rvm reset .

+3
source

Source: https://habr.com/ru/post/1489600/


All Articles