Kitchen/berkshelf wants old gem?

2019-09-07 02:54发布

I want to test some changes to a cookbook, so I did what I used to do, but the result was far from normal:

$ ../gem-sucks/bin/kitchen converge
-----> Starting Kitchen (v1.2.1)
!!!!!! The `berkshelf' gem is missing and must be installed or cannot be properly activated. Run `gem install berkshelf` or add the following to your Gemfile if you are using Bundler: `gem 'berkshelf'`.
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::UserError
>>>>>> Message: Could not load or activate Berkshelf (can't activate json-1.8.0, already activated json-1.8.1)
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

$ gem list | grep berkshelf
berkshelf (3.2.1, 3.1.4, 2.0.10, 2.0.9)
berkshelf-api-client (1.2.0)
$ gem list | grep json
json (1.8.1, 1.8.0)
multi_json (1.10.1, 1.7.9)

The machine is running debian Jessie, and lots of packages (I have no idea whether anything ruby related is among) has been updated since I touched this cookbook last.

How do I make kitchen work again?

4条回答
地球回转人心会变
2楼-- · 2019-09-07 03:25

Look this issue https://github.com/test-kitchen/kitchen-vagrant/pull/126

you need re install berkshelf by gem, then apply patch kitchen-vagrant

Install upstream kitchen-vagrant

git clone https://github.com/test-kitchen/kitchen-vagrant.git
cd kitchen-vagrant
gem build kitchen-vagrant.gemspec
gem install kitchen-vagrant-0.15.0.gem

Re install old Berkshelf

gem install berkshelf
查看更多
唯我独甜
3楼-- · 2019-09-07 03:35

If you're using ChefDk, then you might be able to fix the problem by deleting the gems installed at GEM_HOME (in my case /home/username/.chefdk).

If that doesn't work, try using bundle as in bundle exec kitchen converge, this should allow you to use the installed gems in your list.

查看更多
做自己的国王
4楼-- · 2019-09-07 03:43

Make sure that the chefdk is in the front of your path.

PATH=/opt/chefdk/bin:/Users/sowen/.rvm/gems/ruby-2.2.0/bin:/Users/sowen/.rvm/gems/ruby-2.2.0@global/bin:/Users/sowen/.rvm/rubies/ruby-2.2.0/bin:/opt/chefdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sowen/go/bin:/Users/sowen/.rvm/bin:/Users/sowen/.rvm/bin:/Users/sowen/go/bin

I ran into this same problem until I adjusted and re-sourced my bash_profile

查看更多
你好瞎i
5楼-- · 2019-09-07 03:43

I had a similar issue but json wasn't installed in GEM_HOME and I ended up having to run the following command to resolve my issue.

gem uninstall -i /opt/chefdk/embedded/lib/ruby/gems/2.1.0 json
查看更多
登录 后发表回答