berkshelf / vagrant-berkshelf

A Vagrant plugin to add Berkshelf integration to the Chef provisioners

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not determine Berks version. v3.0.0

dkinzer opened this issue · comments

RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x0000000338ef98 @exitstatus=1, @s
tdout="", @stderr="/home/dkinzer/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs
': Could not find 'berkshelf' (>= 0) among 90 total gem(s) (Gem::LoadError)\n\tfrom /home/dkinzer/.rbenv/vers
ions/2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'\n\tfrom /home/dkinzer/.rbenv/versions/2.1.2
/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'\n\tfrom /home/dkinzer/.rbenv/versions/2.1.2/bin/b
erks:22:in `<main>'\n">                                                                                      

I'm getting this error after upgrading the vagrant-berkshelf plugin:

Version details:

(website)(website-1404)$vagrant version && vagrant plugin list 
Installed Version: 1.6.3                                       
Latest Version: 1.6.3                                          

You're running an up-to-date version of Vagrant!               
librarian-chef (0.0.4)                                         
vagrant-berkshelf (3.0.0)                                      
vagrant-login (1.0.1, system)                                  
vagrant-omnibus (1.4.1)                                        
vagrant-rackspace (0.1.9)                                      
vagrant-share (1.1.0, system)                                  

Gemfile

source "https://rubygems.org"       

gem "knife-solo"                    
gem "knife-solo_data_bag"           
gem "foodcritic"                    
gem "fog"                           
gem "berkshelf"                     

Vagrantfile

# berkshelf
 config.berkshelf.only = [                        
   "./attributes",                                
   "./recipes",                                   
   "./roles",                                     
   "./data_bags",                                 
   "./templates",                                 
   "./files",                                     
   "./metadata.rb",                               
   "./Thorfile",                                  
   "./Gemfile",                                   
   "./Berksfile",                                 
   "./test",                                      
 ]                                                
 config.berkshelf.enabled = true               

@dkinzer can you completely remove the vagrant-berskhelf plugin and re-install?

I tried that, but I'll try it again. I was just about to see if changing the --plugin-source option had an effect.

OK, I see a message now about installing ChefDK so i'll go do that.

@sethvargo I'm on Ubuntu 14.04 and there's no ChefDK package for it.

you can use the 13.10 ChefDK on Ubuntu 14.04 ... but you may have issues with gecode ( 14.04 comes with > 4 )

OK... Side Note: the template variables on the cdk download page are not updating...

Installation Instructions

Run:

{{ downloaded.command }} {{ downloaded.package }}
The chef command and the other commands included with the Chef Development Kit should now be available for use on the command line.

What's in the Cupboard?

I'm still getting the same error after I installed cdk. I'll need to give up on this for now and use librarian chef in the mean time.

@dkinzer it's because your $PATH variable needs to be modified. /opt/chefdk/bin needs to be present before your RBENV bits.

@reset yeah that did the trick! thanks! (Dam rbenv!).

@dkinzer no problem, I'm glad that helped. I'll update the homepage to ensure those instructions are clear.

@reset FYI the same issue occurs with rvm (Ubuntu 14.04)

Can you provide a link to the updated instructions for reference purposes? Can't seem to find them...

@rchekaluk pretty simple step: ensure that the Chef-DK directories are at the front of your $PATH

$ PATH=$HOME/.chefdk/gem/ruby/2.1.0/bin:/opt/chefdk/bin:$PATH

These instructions are now on the front page of berkshelf.com at the top

I have an similar issue in version 3.0.1 by running vagrant up.
The project was initialized with berks cookbook NAME.
I don't have any ~/.chefdk folder

==> default: The cookbook path '/Users/hschaeidt/.berkshelf/default/vagrant/berkshelf-20140806-24154-pmgygf-default' doesn't exist. Ignoring...
Updating Vagrant's berkshelf: '/Users/hschaeidt/.berkshelf/default/vagrant/berkshelf-20140806-24154-pmgygf-default'
RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x000001010959c8 @exitstatus=1, @stdout="", @stderr="/Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'berkshelf' (>= 0) among 57 total gem(s) (Gem::LoadError)\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'\n\tfrom /opt/chefdk/bin/berks:22:in `<main>'\n">

I'm running on latest OSX Mavericks. My ruby version comes from homebrew and overrides the systems ruby. But when I'm using systems default ruby I'm running into the same issue.

vagrant 1.6.3
vagrant-berkshelf (3.0.1)
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.0, system)
chef-dk 0.2.0
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

Any ideas?

@hschaeidt It looks like you have the exact same problem that the others in this thread are having. Your $PATH needs to have the ChefDK directories listed first. It appears that the Vagrant directory is taking precedence in your case.

@reset I am having the exact same issue as @hschaeidt reported. I included both directories in front of my path and am still having the issue.

vagrant 1.6.3
vagrant-berkshelf (3.0.1)
vagrant-cachier (0.8.0)
vagrant-hostmanager (1.5.0)
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.0, system)
Chef Development Kit Version: 0.2.0
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]

any thoughts?

[lzarou@MAC-QA-LZ redisio (test_kitchen_int ✗)]$ echo $PATH
/Users/lzarou/.chefdk/gem/ruby/2.1.0/bin:/opt/chefdk/bin:/Users/lzarou/.gvm/vertx/current/bin:/Users/lzarou/.gvm/springboot/current/bin:/Users/lzarou/.gvm/lazybones/current/bin:/Users/lzarou/.gvm/groovyserv/current/bin:/Users/lzarou/.gvm/groovy/current/bin:/Users/lzarou/.gvm/griffon/current/bin:/Users/lzarou/.gvm/grails/current/bin:/Users/lzarou/.gvm/gradle/current/bin:/Users/lzarou/.gvm/glide/current/bin:/Users/lzarou/.gvm/gaiden/current/bin:/Users/lzarou/.gvm/crash/current/bin:/opt/chefdk/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
[lzarou@MAC-QA-LZ redisio (test_kitchen_int ✗)]$ which berks
/opt/chefdk/bin/berks
[lzarou@MAC-QA-LZ redisio (test_kitchen_int ✗)]$ vagrant up
Bringing machine 'redisio' up with 'virtualbox' provider...
==> redisio: The cookbook path '/Users/lzarou/.berkshelf/redisio/vagrant/berkshelf-20140806-48264-168ltxt-redisio' doesn't exist. Ignoring...
Updating Vagrant's berkshelf: '/Users/lzarou/.berkshelf/redisio/vagrant/berkshelf-20140806-48264-168ltxt-redisio'
RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x00000100b60f20 @exitstatus=1, @stdout="", @stderr="/Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'berkshelf' (>= 0) among 59 total gem(s) (Gem::LoadError)\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'\n\tfrom /opt/chefdk/bin/berks:22:in `<main>'\n">
[lzarou@MAC-QA-LZ redisio (test_kitchen_int ✗)]$

@reset just double-checked. I have the ChefDK repos in front of my $PATH.

$ PATH=$HOME/.chefdk/gem/ruby/2.1.0/bin:/opt/chefdk/bin:$PATH
$ echo $PATH
/Users/hschaeidt/.chefdk/gem/ruby/2.1.0/bin:/opt/chefdk/bin:/opt/chefdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'chef/ubuntu-14.04' is up to date...
==> default: The cookbook path '/Users/hschaeidt/.berkshelf/default/vagrant/berkshelf-20140806-24154-pmgygf-default' doesn't exist. Ignoring...
Updating Vagrant's berkshelf: '/Users/hschaeidt/.berkshelf/default/vagrant/berkshelf-20140806-24154-pmgygf-default'
RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x00000101b77fa8 @exitstatus=1, @stdout="", @stderr="/Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'berkshelf' (>= 0) among 51 total gem(s) (Gem::LoadError)\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'\n\tfrom /opt/chefdk/bin/berks:22:in `<main>'\n">

/Users/hschaeidt/.chefdk/gem/ruby/2.1.0/bin this folder does not exist. May that be the issue, how to set it up?

@zarry did you find a solution?

@reset @hschaeidt I have not found a solution yet. I am still looking for resolution to this issue. Any help would be appreciated.

@zarry I have pretty much the same config as you except my ChefDK version is 0.1.0 and vagrant up is now working for me:

Chef Development Kit Version: 0.1.0

vagrant-berkshelf (3.0.1)
vagrant-librarian-chef (0.2.1)
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
vagrant-rackspace (0.1.9)
vagrant-share (1.1.0, system)

ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

@dkinzer @hschaeidt @reset Wondering if we should open a new issue at this point. This one is closed and does not seem to be getting attention...

Yeah, Is there a gitter or irc channel for this project? Maybe bring it up there would work too.

@zarry I reopened this issue on your behalf.

It's not getting attention because I don't have an answer. I haven't been able to reproduce this on any of my co-workers machines either.

I'll update when I discover more. Ruby is simply shelling out to a binary on disk. Not sure what is getting mangled along the way yet!

ok, please let me know if you need me to run anything diagnostically or get back to you with any specific info.

I possibly might try uninstalling/reinstalling the slew of vagrant/vagrant plugins/chefdk and see if I have any better luck. If I go that route I will update here with results.

I'm having this same problem. Mac OS X 10.7 (Lion); too old for ChefDK. System ruby install has berkshelf, but while vagrant can find berks, berks can't find its own gem.

RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x00000102207198 @exitstatus=1, @stdout="", @stderr="/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/dependency.rb:313:in `to_specs': Could not find 'berkshelf' (>= 0) among 49 total gem(s) (Gem::LoadError)\nChecked in 'GEM_PATH=/Users/cmalek/.vagrant.d/gems:/Applications/Vagrant/bin/../embedded/gems', execute `gem env` for more information\n\tfrom /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/dependency.rb:322:in `to_spec'\n\tfrom /opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb:58:in `gem'\n\tfrom /opt/local/bin/berks:22:in `<main>'\n">

It seems as though the system ruby is somehow only importing vagrant's embedded gems instead of the ones that it owns. Vagrant has 49 embedded gems, yet there are only 46 installed in the system ruby.

Possibly environment smashing happening? Vagrant's own environment somehow getting passed to through the system() to the ruby used by berks?

Hmm, yes, I can see that in /usr/bin/vagrant we have this on lines 22-25:

# Export gem paths so that we use the isolated gems.
export GEM_PATH="${EMBEDDED_DIR}/gems"
export GEM_HOME="${GEM_PATH}"
export GEMRC="${EMBEDDED_DIR}/etc/gemrc"

so that when you do the shell_out() call in Berkshelf::Vagrant::EnvHelpers.berks_version_check to execute berks, the ruby that berks was built for forgets its own GEM_HOME and GEM_PATH and uses vagrant's. Which, of course, does not have berkshelf installed.

@cmalek we can clear those env variables out but I'm surprised that this line in the generated /opt/chefdk/bin/berks stub isn't overriding it for us:

#!/opt/chefdk/embedded/bin/ruby
#--APP_BUNDLER_BINSTUB_FORMAT_VERSION=1--
ENV["GEM_HOME"] = ENV["GEM_PATH"] = nil unless ENV["APPBUNDLER_ALLOW_RVM"] == "true"

There might be some additional repercussions that we should consider by just nilling out those three env variables when we shell out.

@reset Thank you for looking into it! I'm sorry to have confused the issue.

I have not been using the chefdk since I'm on Lion and the latest version of ChefDK claims to only work on Mavericks. I was hoping to get this to work with my regular system ruby or a rbenv version of ruby. The berks that gets installed when you do gem install berkshelf doesn't have the code you mentioned above. It feels icky to me that vagrant smashes GEM_PATH and GEM_HOME thus tainting any system() calls to ruby scripts, and I was hoping there was an easy fix for that.

I'm currently biting the bullet and upgrading to Mavericks. Then I will download ChefDK and report back.

@cmalek ah, we're still having this report for people who aren't using ChefDK as well so it's worth investigating

I'm having the same problem. I installed the berkshelf using gem install.

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'precise64'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: chef_default_1407845055840_62296
Updating Vagrant's berkshelf: '/Users/robinho/.berkshelf/default/vagrant/berkshelf-20140812-22646-4q2coc-default'
RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x00000101365c20 @exitstatus=1, @stdout="", @stderr="/Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'berkshelf' (>= 0) among 66 total gem(s) (Gem::LoadError)\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'\n\tfrom /Users/robinho/.rvm/gems/ruby-1.9.3-p547@jusbrasil/bin/berks:22:in `<main>'\n\tfrom /Users/robinho/.rvm/gems/ruby-1.9.3-p547@global/bin/ruby_executable_hooks:15:in `eval'\n\tfrom /Users/robinho/.rvm/gems/ruby-1.9.3-p547@global/bin/ruby_executable_hooks:15:in `<main>'\n">

$ berks --version
3.1.5

$ vagrant plugin list
vagrant-berkshelf (3.0.1)
vagrant-hostmanager (1.5.0)
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.0, system)
vagrant-vbguest (0.10.0)

$ gem list

*** LOCAL GEMS ***

addressable (2.3.6)
berkshelf (3.1.5)
berkshelf-api-client (1.2.0)
bigdecimal (1.1.0)
buff-config (1.0.1)
buff-extensions (1.0.0)
buff-ignore (1.1.1)
buff-ruby_engine (0.1.0)
buff-shell_out (0.2.0)
bundler (1.6.5, 1.6.2)
bundler-unload (1.0.2)
celluloid (0.16.0.pre3)
celluloid-io (0.16.0.pre2)
chef (11.12.8)
chef-zero (2.0.2)
coderay (1.1.0)
dep-selector-libgecode (1.0.2)
dep_selector (1.0.3)
diff-lcs (1.2.5)
erubis (2.7.0)
executable-hooks (1.3.1)
faraday (0.9.0)
ffi (1.9.3)
foodcritic (4.0.0)
gem-wrappers (1.2.4)
gherkin (2.12.2)
hashie (2.1.2)
highline (1.6.21)
hitimes (1.2.2)
io-console (0.3)
ipaddress (0.8.0)
json (1.8.1, 1.5.5)
method_source (0.8.2)
mime-types (1.25.1)
mini_portile (0.6.0)
minitar (0.5.4)
minitest (2.5.1)
mixlib-authentication (1.3.0)
mixlib-cli (1.5.0)
mixlib-config (2.1.0)
mixlib-log (1.6.0)
mixlib-shellout (1.4.0)
multi_json (1.10.1)
multipart-post (2.0.0)
net-http-persistent (2.9.4)
net-ssh (2.9.1)
net-ssh-gateway (1.2.0)
net-ssh-multi (1.2.0)
nio4r (1.0.0)
nokogiri (1.6.3.1)
octokit (3.3.0)
ohai (7.0.4)
polyglot (0.3.5)
pry (0.10.0)
rack (1.5.2)
rake (10.3.2, 0.9.2.2)
rdoc (4.1.1, 3.9.5)
rest-client (1.6.8)
retryable (1.3.5)
ridley (4.0.0)
rubygems-bundler (1.4.3)
rufus-lru (1.0.5)
rvm (1.11.3.9)
sawyer (0.5.4)
semverse (1.2.1)
slop (3.6.0)
solve (1.2.1)
systemu (2.5.2)
thor (0.19.1)
timers (4.0.0)
treetop (1.5.3)
varia_model (0.4.0)
yajl-ruby (1.2.1)

not sure this will only add confusion to the matter, but just in case... I just started a new project and I got a notice that I was missing a .chefdk Gem folder

      create  .kitchen.yml                                                                             │······      create  test/integration/default                                                                 │······
Fetching: kitchen-vagrant-0.15.0.gem (100%)                                                            │······
WARNING:  You don't have /home/dkinzer/.chefdk/gem/ruby/2.1.0/bin in your PATH,                        │······
          gem executables will not run.                                                                │······
Successfully installed kitchen-vagrant-0.15.0                                                          │······
Parsing documentation for kitchen-vagrant-0.15.0                                                       │······
Installing ri documentation for kitchen-vagrant-0.15.0                                                 │······
Done installing documentation for kitchen-vagrant after 0 seconds                                      │······
1 gem installed 

It's true that there's no folder there, but now I'm wondering if maybe we should be sym liking the rbenv bin folder to it or some other folder?

Is the common denominator rbenv here? For those who have listed (or provided stacktraces) all I see is rbenv. The way rbenv handles symlinks and "shims" is a bit crazy if you ask me. If people could confirm they are running rbenv, it would help us look where to debug.

I'm not. I'm using system wide the newest homebrew version. But if I switch back to OSX std ruby I get stucked in the same issue.

@sethvargo I was using a system wide MacPorts version of ruby-1.9.3. I did try rbenv also, but that gave me similar results.

@sethvargo I am not using rbenv either. I installed ruby via homebrew install.

@sethvargo I'm pretty confident at this point that these reports are either Vagrant stepping on the users environment variables or a misconfigured path. I made some changes to buff-shell_out but haven't had the time to integrate them back into vagrant-berkshelf to see if sanitizing the path myself works.

Same issue, chefdk 0.2 installed. I am using rbenv w/ OSX 10.10

$ vagrant provision                                                                        ±[●●][master]
==> default: The cookbook path '/Users/jdyer/.berkshelf/default/vagrant/berkshelf-20140526-36303-1124962-default' doesn't exist. Ignoring...
Updating Vagrant's berkshelf: '/Users/jdyer/.berkshelf/default/vagrant/berkshelf-20140526-36303-1124962-default'
RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x00000102b7f608 @exitstatus=1, @stdout="", @stderr="/Users/jdyer/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'berkshelf' (>= 0) among 75 total gem(s) (Gem::LoadError)\n\tfrom /Users/jdyer/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'\n\tfrom /Users/jdyer/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'\n\tfrom /Users/jdyer/.rbenv/versions/2.1.1/bin/berks:22:in `<main>'\n">

# jdyer at MacBook-Pro.local in ~/Projects/

Ruby

# jdyer at MacBook-Pro.local in ~/Projects/tropo_projects/ruby_transfer_agent on git:master x [16:36:36]
$ ruby -v                                                                                  ±[●●][master]
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]

Vagrant

# jdyer at MacBook-Pro.local in ~/Projects/tropo_projects/ruby_transfer_agent on git:master x [16:40:04]
$ vagrant -v                                                                               ±[●●][master]
Vagrant 1.6.3

Vagrant Plugins

# jdyer at MacBook-Pro.local in ~/Projects/tropo_projects/ruby_transfer_agent on git:master x [16:39:29]
$ vagrant plugin list                                                                      ±[●●][master]
vagrant-aws (0.5.0)
vagrant-berkshelf (3.0.1)
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.0, system)
vagrant-vbguest (0.10.0)

Just to follow up, I confirm that after upgrading to Mavericks, installing ChefDK and reinstalling vagrant, vagrant up works properly and no longer throws RuntimeError: Couldn't determine Berks version.

I'm not trying to throw too many "doesn't work on my machine" comments, but this is happening to a coworker of mine and I. I decided to downgrade the plugin to the 2.0.1 version, and this error does not show up. I suppose this may have to do with less reliance on chefdk.

I also did try the PATH fix and I am using a chruby/ruby-install setup.

If it helps, I can reproduce this issue. I discovered two more workarounds that appear to be necessary, at least on Mac OS X machines, besides the PATH fix. I tested this on OS X Mavericks 10.9 and with the ChefDK 0.2.0-2.

  1. If there is no "/opt" directory, the ChefDK creates the "/opt" tree writeable only by root (on Mac OS X, and perhaps Linux), and when you run "vagrant up", it looks like the "ffi" gem thinks it needs to be built, which requires the "/opt" tree to be user-writeable. A hacky workaround is to make "/opt/chefk" user-writeable. (Technically it only needs to be the gem lib tree). The reason why people can't always reproduce this is that I believe the "/opt" tree is created by other software being user-writeable with a corresponding umask, and the ChefDK install will respect this.
  2. If you have Xcode 5.1 (or higher) installed, if vagrant-berkshelf needs to install some gems that need native extensions compiled, you'll hit the infamous "-Wunused-command-line-argument-hard-error-in-future" issue, as the new compiler doesn't respect some of the gcc compiler flags that used to work previously. For more info on a workaround, refer to the following: https://langui.sh/2014/03/10/wunused-command-line-argument-hard-error-in-future-is-a-harsh-mistress/

@misheska That workaround does not seem to be doing it for me. I tried all three of those in place simultaneously and I am still seeing the error.

@drag00n I think that 2.0.1 works for you because the problematic bit -- the shelling out to run berks to get its version -- was only added recently to the 3.x versions.

Not sure exactly what I did as I was in a fury of uninstall/reinstall/reconfigure but I managed to get it working.

What might have been the golden ticket was removing vagrant entirely. Putting chefdk at front of path, then reinstalling vagrant and all the plugins(with chefdk in front of path). I initially hit a wall installing the vagrant-berkshelf plugin with this approach. Resolved that by executing the plugin install with sudo. It was attempting to write to the embedded /Applications/Vagrant/embedded/gems directory which is owned by root without sudo it could not properly install that gem.

Once I ran vagrant-install with sudo it successfully installed after that, vagrant up was working with berkshelf and the vagrant-berkshelf plugin.

Thanks to everyone who attempted to help me troubleshoot and hopefully the little bit of information I provided back can help someone else.

To reiterate, fix for this is

export PATH='/opt/chefdk/bin:'$PATH

Put this in your ~/.bashrc file at the bottom

@john5223 only if you're using chefdk. If people have their Mountain Lion or earlier on their Mac, there is no ChefDK available, so that advice doesn't work for them. Or if they want to use their own version of ruby.

I ran today through this issue, followed your instructions to update the PATH, but with no success.
I had an underliyng problem i've discovered running:
berks --version

 /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/buff-config-1.0.0/lib/buff/config/ruby.rb:30:in `rescue in initialize': undefined local variable or method `current_dir' for #<Buff::Config::Ruby::Evaluator:0x007fa532c86ca0>

In my knife.rb was missing the key current_dir.
Adding this line to the knife.rb everything worked fine.

current_dir = File.dirname(__FILE__)

Hope it helps.

P.S. I'm running OSX Mavericks.

Just an update. I have been able to work around this by using the chefdk cask in homebrew. In my bash_profile I have the path for homebrew (thus chefdk) listed before my rbenv entry. So I think this does support the provided fix for my environment. I'm not sure why this did not work properly before when I specified /opt/chefdk directly.

So I see a couple problems at the moment.

  1. GEM_HOME, GEM_PATH, and GEMRC are all set by Vagrant to vagrant values.
  2. The PATH is altered so that Vagrants embedded ruby is added near the front.

2 causes problems when using bundle install --binstubs because the shebang line is #!/usr/bin/env ruby (and this runs Vagrant's ruby).

It can also cause problems depending on how you set up your ruby's binstubs, since they may (or may not) be using the #!/usr/bin/env ruby shebang as well.

My suggestion is to find a different way to shell out (or an option to the shellout code) that doesn't monkey with the PATH and GEM* environment variables.

My local dev environment just got destroyed by whatever this bug is, I was able to provision vagrant boxes this morning but now can't. The only significant change I made to my machine today was installing ChefSpec for the first time to test a cookbook that was using vagrant/berkshelf. The specs run, but I can't vagrant up/provision in that cookbook (for manual verification.) I also can't vagrant up/provision in a different repo for a rails app that also used vagrant/berkshelf for bootstrapping the execution environment.

I realize this isn't the best report, but perhaps the the fact that I installed and used ChefSpec for the first time today may trigger someone's thought process.

Really hope we can figure this one out, my entire development environment for like 10 software projects is hosed at the moment.

/cc @sethvargo

I've found that prepending gem wrapper path (gem wrappers prints it) to PATH makes it use a gem wrapper that resets the environment, thus making it work.

Confirmed: At least in my case, installing ChefSpec is the cause of the breakage, likely something to do with it installing one or more of:

  • berkshelf-api-client
  • berkshelf
  • chef
  • chef-zero

My guess is that these gems being installed directly are causing a conflict with my vagrant/vagrant-berkshelf/chefdk configuration.

/cc @sethvargo

Output from a cookbook managed with vagrant-berkshelf and as of yesterday tested with ChefSpec (when my problems started). Previous to this I completely uninstalled everything related to chef and vagrant from my machine and reinstalled.

$ vagrant up
Bringing machine 'default' up with 'vmware_fusion' provider...
...
$ vagrant ssh
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-24-generic x86_64)
...
$ vagrant destroy -f
==> default: Stopping the VMware VM...
==> default: Deleting the VM...
==> default: Running cleanup tasks for 'chef_solo' provisioner...
$ bundle
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Using rake (10.1.1)
Using addressable (2.3.6)
Using multipart-post (2.0.0)
Using faraday (0.9.0)
Installing berkshelf-api-client (1.2.0)
Using buff-extensions (0.5.0)
Using hashie (2.1.2)
Using varia_model (0.3.2)
Using buff-config (0.4.0)
Using buff-ruby_engine (0.1.0)
Using buff-shell_out (0.2.0)
Using hitimes (1.2.2)
Using timers (4.0.0)
Using celluloid (0.16.0.pre3)
Using nio4r (1.0.0)
Using celluloid-io (0.16.0.pre2)
Using minitar (0.5.4)
Using sawyer (0.5.5)
Using octokit (2.7.2)
Using retryable (1.3.5)
Using buff-ignore (1.1.1)
Using erubis (2.7.0)
Using json (1.8.1)
Using mixlib-log (1.6.0)
Using mixlib-authentication (1.3.0)
Using net-http-persistent (2.9.4)
Using semverse (1.2.1)
Using ridley (3.1.0)
Using dep-selector-libgecode (1.0.2)
Using ffi (1.9.3)
Using dep_selector (1.0.3)
Using solve (1.2.1)
Using thor (0.19.1)
Installing berkshelf (3.0.1)
Using rack (1.5.2)
Installing chef-zero (2.2)
Using diff-lcs (1.2.5)
Using libyajl2 (1.0.1)
Using ffi-yajl (1.0.2)
Using highline (1.6.21)
Using mime-types (1.25.1)
Using mixlib-cli (1.5.0)
Using mixlib-config (2.1.0)
Using mixlib-shellout (1.4.0)
Using net-ssh (2.9.1)
Using net-ssh-gateway (1.2.0)
Using net-ssh-multi (1.2.0)
Using ipaddress (0.8.0)
Using systemu (2.6.4)
Using wmi-lite (1.0.0)
Using ohai (7.2.4)
Using plist (3.1.0)
Using coderay (1.1.0)
Using method_source (0.8.2)
Using slop (3.6.0)
Using pry (0.10.1)
Using rest-client (1.6.7)
Installing chef (11.14.6)
Using fauxhai (2.2.0)
Using rspec-support (3.0.4)
Using rspec-core (3.0.4)
Using rspec-expectations (3.0.4)
Using rspec-mocks (3.0.4)
Using rspec (3.0.0)
Installing chefspec (4.0.2)
Using bundler (1.5.1)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
$ vagrant up
Bringing machine 'default' up with 'vmware_fusion' provider...
==> default: Cloning VMware VM: 'opscode_ubuntu-14.04_chef-provisionerless'. This can take some time...
==> default: Verifying vmnet devices are healthy...
RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x000001029bf1d8 @exitstatus=1, @stdout="", @stderr="/Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'berkshelf' (>= 0) among 60 total gem(s) (Gem::LoadError)\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'\n\tfrom /usr/bin/berks:22:in `<main>'\n">
$

Edit: Also verified that simply uninstalling chefspec and all of the chef/berks-related gems it installs and then reinstalling chefdk makes everything work again.

What kind of ChefSpec stuff do you have? Is there a spec_helper or anything? Are other people in this thread using ChefSpec?

@sethvargo It's a very simple setup, just a couple of very basic recipe specs ensuring that packages are installed, etc.

spec_helper.rb

require 'chefspec'
require 'chefspec/berkshelf'
ChefSpec::Coverage.start!

RSpec.configure do |config|
  config.log_level = :error
  config.platform = 'ubuntu'
  config.version = '14.04'
end

What if you remove the require chefspec/berkshelf line?

It's not ChefSpec. It is running the wrong ruby with the wrong environment variables.

@sethvargo No dice, I didn't imagine it would be. Simply running bundle in my cookbook which in turn installs ChefSpec immediately makes it so I cannot provision any vagrant VMs (even ones in other projects/repos/directories.) I can repeat this in isolation over and over.

  • vagrant up/provision: works
  • bundle: Installs chefspec
  • vagrant up/provision: stops working
  • gem uninstall berkshelf berkshelf-api-client chef chef-zero chefspec
  • Reinstall chefdk
  • vagrant up/provision: starts working again

Not necessarily saying this is ChefSpec's fault, but something about this is definitely related to the breakage in my case.

As a side note, I use a crapton of software that has your contributions in it, you are awesome and thank you for writing awesome tools.

@dpehrson I think @docwhat is right - this is a Ruby issue. The fact that you're seeing it when ChefSpec is in your bundle may be related (because ChefSpec requires Chef, which brings along an entire universe of gems that could muck with the system), but I think it's a redherring tbh.

If you're using ChefDK, why aren't you using chef gem uninstall/install?

Yeah, at the end of the day the underlying cause is obviously some sort of environment conflict which may not be anyone individual component's fault, it could just be odd interactions between a lot of things. In my case I've found out how to work around it so my problem is solved.

Here's some more enviornment information in case it helps:

$ uname -a
Darwin computer.local 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun  3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
$ vagrant version
Installed Version: 1.6.3
Latest Version: 1.6.3

You're running an up-to-date version of Vagrant!
$ vagrant plugin list
vagrant-berkshelf (3.0.1)
vagrant-hostmanager (1.5.0)
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.0, system)
vagrant-vmware-fusion (2.5.2)

Ultimately for the projects I am working on the setup to work within them is:

  1. Install VMWare Fusion
  2. Install Vagrant (1.6.3)
  3. Install vagrant-vmware-fusion (2.5.2)
  4. Install vagrant-omnibus (1.4.1)
  5. Install vagrant-berkshelf (3.0.1)
  6. Install ChefDK (0.2.0)
  7. Install vagrant-hostmanager (1.5.1)

At that point all my vagrant machines (whether they be cookbook repos, rails execution environments, etc.) properly run.

As soon as I go into my cookbook and bundle (which in turn installs chefspec) I can no longer provision vagrant boxes anywhere.

Again, I don't think that this is necessarily the fault of any one component, but there is something about that setup that is one vector by which you can reliably recreate this problem.

As far as the chef gem, nowhere in my process do I directly install or uninstall the chef gem. I just have to uninstall it directly after chefspec installs it as a dependency to fix my system once it's broken.

Once again, thanks to everyone for all the help and for all the awesome tools. If nothing else I hope this may assist other people in working around the issue until we have a solid understanding of exactly what's going on even if this is just a red herring.

Moving forward I just won't bundle my cookbook on the host machine and rather run my chefspecs within the guest vagrant box.

Sorry to keep spamming you all, but I think I may have found the actual problem and as suggested, it is not chefspec.

If you install ChefDK, /usr/bin/berks is symlinked to /opt/chefdk/bin/berks

If you later install the berkshelf gem either directly or through a bundle, the /usr/bin/berks symlink is replaced with the actual berks binary from the gem. This may be why the environment gets screwed up when vagrant-berkshelf later tries to use berks assuming it is the ChefDK berks when it is in fact the berks from the gem directly.

Here's a log outlining the problem in the simplest way I can find to recreate it from within my cookbook where this all started:

# At this starting point I can provision vagrant boxes.
$ which berks
/usr/bin/berks
$ ls -l /usr/bin/berks
lrwxr-xr-x  1 root  wheel  21 Aug 27 12:08 /usr/bin/berks -> /opt/chefdk/bin/berks
$ bundle
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
...
Installing berkshelf (3.1.5)
...
$ which berks
/usr/bin/berks
$ ls -l /usr/bin/berks
-rwxr-xr-x  1 root  wheel  466 Aug 27 12:06 /usr/bin/berks
$ rake
...
Finished in 12.09 seconds (files took 3.92 seconds to load)
24 examples, 0 failures
$ vagrant up
Bringing machine 'default' up with 'vmware_fusion' provider...
==> default: Cloning VMware VM: 'opscode_ubuntu-14.04_chef-provisionerless'. This can take some time...
==> default: Verifying vmnet devices are healthy...
RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x000001021bd0e8 @exitstatus=1, @stdout="", @stderr="/Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'berkshelf' (>= 0) among 60 total gem(s) (Gem::LoadError)\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'\n\tfrom /usr/bin/berks:22:in `<main>'\n">
$ sudo rm /usr/bin/berks
$ sudo ln -s /opt/chefdk/bin/berks /usr/bin/berks
$ rake
...
Finished in 12.09 seconds (files took 3.92 seconds to load)
24 examples, 0 failures
$ vagrant up
...
$ vagrant ssh
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-24-generic x86_64)

So it appears if you are using vagrant-berkshelf/ChefDK and you later install the berkshelf gem, you need to fix /usr/bin/berks to point back to the ChefDK binary.

Once I did that, I can both provision VM's and run my chef specs.

EDIT: Also, It does not appear you can fix this by prioritizing /opt/chefdk/bin over /usr/bin in your PATH either unfortunately, I truly have to fix the symlink.

Right. As I said, it is because when running berks from vagrant it is overriding too much of the environment.

@sethvargo: Can we do something like (pseudo code):

if Gemfile exists?
  run 'berks' from path with clean environment (e.g. no rearranged path, etc)
else
  run '/opt/chefdk/bin/berks' with clean environment
end

@docwhat Vagrant is overriding the environment - the fix is to reset the environment back to a sane place when we shell out. The necessary changes have been made to the buff-shell_out gem but the work hasn't been done in vagrant-berkshelf just yet.

@reset How about running /opt/chefdk/bin/berks if a Gemfile doesn't exist? That should allow non-chefdk users and chefdk users both to work, right?

@docwhat no, there is a better way to determine if we're running inside a Bundler environment and we can't use a hardcoded path to find berkshelf since a user could install the ChefDK to a different location.

For what it's worth, downgrading to chefdk 0.1.0 worked for me (and I tried everything else above).

Well, I'll add my $0.02. More in hope that it helps someone than because I found the error cause.

Mavericks, using macports.

Been having this problem for days, have installed and uninstalled stuff, no good. Also tweaked and retweaked the path settings in .profile (see below). In my case, at least, it was not "just" tweaking the path however.

What seems to have done the trick was to re-install chefdk & vagrant, and aggressively remove all related config directories before re-installing chefdk and vagrant. Could the ~/.gem or something else have been holding on to a bad nokogiri?

afterwards:
export PATH=:$HOME/.chefdk/gem/ruby/2.1.0/bin:/opt/chefdk/bin:/opt/chefdk/embedded/bin:$PATH

versions and paths:

/opt/chefdk/embedded/bin/ruby
/opt/chefdk/embedded/bin/gem
/opt/chefdk/embedded/bin/bundler
/usr/bin/vagrant
Vagrant 1.6.3
Chef Development Kit Version: 0.2.0
3.1.3

vagrant-berkshelf (3.0.1)
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.0, system)

removing ~/.xxx config directories

(I actually moved them to a backup directory, just in case. script did not work well, but I did not have all those ~/.chefdk and other directories once it was done).

rm -rf /Users/myuser/.gem would probably do the trick. rm ~/.gem might not if you are running it sudo.

mv ~/.gem .
mv ~/.chefdk .
mv ~/.bundle .
mv ~/.bundler .
mv ~/.berkshelf .
mv ~/.vagrant.d .

what changed:

reinstall of chefdk and vagrant went well, or rather behaved as before.

vagrant plugin install vagrant-omnibus had some errors at first (complaining about an invalid vagrant-share), but redoing it eventually rebuilt nokogiri along the way. This warning and rebuilding behavior was DIFFERENT from all my previous passes trying to fix this by re-installations.

vagrant plugin install vagrant-berkshelf went through without a hitch.

If it is of any help for folks who are running across this thread. I found that on my machine I had previously installed the berkshelf through gem install berkshelf. That needed to be uninstalled. I found this by the fact my colleague asked me to do

which berks

and

which chef

... the paths that were active didn't match up (berks was in my home directory under my .rvm/gems folder and chef was under /usr/bin/chef). After doing a

gem uninstall berkshelf

all was cool in the pool.

re. einsty's posting, that fits in with my situation as well.

I am new to chef so I first installed it by itself. Then, because my machine was already working with chef, I tried to add berkshelf by itself, rather than with Chefdk. I ran into a number of nokogiri build errors which I couldn't solve. So I ended up installing chefdk and the nokogiri issue disappeared.

Chef on its own, from Chefdk, was working at that point, but berkshelf kept having the Berks version error till I flushed out everything from the previous installs by removing their config directories as well as the binaries.

FWIW I am having a similar problem to @cmalek , Environment is OSX 10.7.5 running RVM as the ruby manager. Error output below

~/chef-repo/cookbooks/project(master ✗) vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'chef/ubuntu-14.04' is up to date...
==> default: The cookbook path '/Users/Joshua/.berkshelf/default/vagrant/berkshelf-20140905-87728-fqivar-default' doesn't exist. Ignoring...
Updating Vagrant's berkshelf: '/Users/Joshua/.berkshelf/default/vagrant/berkshelf-20140905-87728-fqivar-default'
RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x00000103b6a888 @exitstatus=1, @stdout="", @stderr="/Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'berkshelf' (>= 0) among 77 total gem(s) (Gem::LoadError)\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'\n\tfrom /Applications/Vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'\n\tfrom /Users/Joshua/.rvm/gems/ruby-2.1.2/bin/berks:22:in `<main>'\n\tfrom /Users/Joshua/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'\n\tfrom /Users/Joshua/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'\n">
~/chef-repo(master ✗) vagrant plugin list
vagrant-berkshelf (3.0.1)
vagrant-login (1.0.1, system)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.1, system)
ruby-2.1.2:

  system:
    uname:       "Darwin Mansfield.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64"
    system:      "osx/10.7/x86_64"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
    zsh:         "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"

  rvm:
    version:      "rvm 1.25.29 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "22 hours 28 minutes 28 seconds ago"
    path:         "/Users/Joshua/.rvm"

  ruby:
    interpreter:  "ruby"
    version:      "2.1.2p95"
    date:         "2014-05-08"
    platform:     "x86_64-darwin13.0"
    patchlevel:   "2014-05-08 revision 45877"
    full_version: "ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]"

  homes:
    gem:          "/Users/Joshua/.rvm/gems/ruby-2.1.2"
    ruby:         "/Users/Joshua/.rvm/rubies/ruby-2.1.2"

  binaries:
    ruby:         "/Users/Joshua/.rvm/rubies/ruby-2.1.2/bin/ruby"
    irb:          "/Users/Joshua/.rvm/rubies/ruby-2.1.2/bin/irb"
    gem:          "/Users/Joshua/.rvm/rubies/ruby-2.1.2/bin/gem"
    rake:         "/Users/Joshua/.rvm/gems/ruby-2.1.2/bin/rake"

  environment:
    PATH:         "/Users/Joshua/.rvm/gems/ruby-2.1.2/bin:/Users/Joshua/.rvm/gems/ruby-2.1.2@global/bin:/Users/Joshua/.rvm/rubies/ruby-2.1.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/usr/local/git/bin:/opt/chef/embedded/bin:/usr/local/bin:/usr/local/sbin:/Users/Joshua/.cabal/bin:/usr/local/share/npm/bin:./bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/X11/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/Users/Joshua/.rvm/bin"
    GEM_HOME:     "/Users/Joshua/.rvm/gems/ruby-2.1.2"
    GEM_PATH:     "/Users/Joshua/.rvm/gems/ruby-2.1.2:/Users/Joshua/.rvm/gems/ruby-2.1.2@global"
    MY_RUBY_HOME: "/Users/Joshua/.rvm/rubies/ruby-2.1.2"
    IRBRC:        "/Users/Joshua/.rvm/rubies/ruby-2.1.2/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

As I am not in a place where upgrading to Mavericks can happen immediately I was hoping that someone found a workaround.

@Dangeranger can you run

which berks

and

which chef

@einsty
Totally, sorry to leave that out.

$  which berks
/Users/Joshua/.rvm/gems/ruby-2.1.2/bin/berks
$ which chef
chef not found 

Note I installed chef as a gem from RubyGems, the Omnibus installers embedded version was not playing well with RVM.

$  which chef-client
/Users/Joshua/.rvm/gems/ruby-2.1.2@global/bin/chef-client

The gem versions are:

  • chef (11.14.6)
  • chef-zero (2.2)

hmm, have you installed the ChefDk?
https://downloads.getchef.com/chef-dk/mac/#/

I don't think chefdk is supported on 10.7

@einsty That's right, it's not compatible with 10.7.5, which is the version of the OS that I am running.

Ahhh. You may not be able to use Berkshelf 3 then either. The new
berkshelf relies on ChefDK.

On Fri, Sep 5, 2014 at 3:41 PM, Joshua Burke notifications@github.com
wrote:

@einsty https://github.com/einsty That's right, it's not compatible
with 10.7.5, which is the version of the OS that I am running.


Reply to this email directly or view it on GitHub
#212 (comment)
.

Orin Fink, managing partner
P 312.340.6503 | C *312.933.3433 | *F 312.329.1963
15 West Hubbard Street, Suite 300 | Chicago, IL 60654

Yep, so I have found similarly to @cmalek that the only "Happy" path here is to upgrade to Mavericks. Which I have now done.

$ which chef
/usr/bin/chef
$ chef --version
Chef Development Kit Version: 0.2.1
$ which berks
/usr/bin/berks

At this point it appears that the ChefDK installer has removed my local gems related to chef and berks... surprised that it took that action but ok. Also Vagrant needed to be reinstalled, although I am unsure if that a result of ChefDK or Mavericks.

Now the cookbooks are getting updated, and vendored. However a Virtual Box error is getting thrown:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'chef/ubuntu-14.04' is up to date...
==> default: The cookbook path '/Users/Joshua/.berkshelf/default/vagrant/berkshelf-20140905-87728-fqivar-default' doesn't exist. Ignoring...
Updating Vagrant's berkshelf: '/Users/Joshua/.berkshelf/default/vagrant/berkshelf-20140905-87728-fqivar-default'
Resolving cookbook dependencies...

Cookbooks are found and vendored successfully

VirtualBox error message below

==> default: Clearing any previously set network interfaces...
Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%...
Progress state: NS_ERROR_FAILURE
VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterface, interface IHostNetworkInterface
VBoxManage: error: Context: "int handleCreate(HandlerArg*, int, int*)" at line 66 of file VBoxManageHostonly.cpp

Looks like the VirtualBox error was caused by an out of date version of VirtualBox.
Upgrading to version: VirtualBox-4.3.14-95030-OSX fixed the errors above.

Thanks for your help, @einsty

Was a resolution to the berkshelf version found?

RuntimeError: Couldn't determine Berks version: #<Buff::ShellOut::Response:0x00000102bc0658 @ExitStatus=1, @stdout="", @stderr="/opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:298:in to_specs': Could not find 'berkshelf' (>= 0) among 51 total gem(s) (Gem::LoadError)\n\tfrom /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:309:in to_spec'\n\tfrom /opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:ingem'\n\tfrom /opt/chefdk/embedded/bin/berks:22:in

'\n">
tcrowdermacmini:myface travis.crowder$ which chef
/opt/chefdk/embedded/bin/chef
tcrowdermacmini:myface travis.crowder$ which berks
/opt/chefdk/embedded/bin/berks
tcrowdermacmini:myface travis.crowder$ ls -alh /usr/bin/ | egrep "berks|chef"
lrwxr-xr-x 1 root wheel 21B Sep 15 13:34 berks -> /opt/chefdk/bin/berks
lrwxr-xr-x 1 root wheel 20B Sep 15 13:34 chef -> /opt/chefdk/bin/chef
lrwxr-xr-x 1 root wheel 26B Sep 15 13:34 chef-apply -> /opt/chefdk/bin/chef-apply
lrwxr-xr-x 1 root wheel 27B Sep 15 13:34 chef-client -> /opt/chefdk/bin/chef-client
lrwxr-xr-x 1 root wheel 26B Sep 15 13:34 chef-shell -> /opt/chefdk/bin/chef-shell
lrwxr-xr-x 1 root wheel 25B Sep 15 13:34 chef-solo -> /opt/chefdk/bin/chef-solo
lrwxr-xr-x 1 root wheel 25B Sep 15 13:34 chef-zero -> /opt/chefdk/bin/chef-zero
lrwxr-xr-x 1 root wheel 23B Sep 15 13:34 fauxhai -> /opt/chefdk/bin/fauxhai
lrwxr-xr-x 1 root wheel 26B Sep 15 13:34 foodcritic -> /opt/chefdk/bin/foodcritic
lrwxr-xr-x 1 root wheel 23B Sep 15 13:34 kitchen -> /opt/chefdk/bin/kitchen
lrwxr-xr-x 1 root wheel 21B Sep 15 13:34 knife -> /opt/chefdk/bin/knife
lrwxr-xr-x 1 root wheel 20B Sep 15 13:34 ohai -> /opt/chefdk/bin/ohai
lrwxr-xr-x 1 root wheel 23B Sep 15 13:34 rubocop -> /opt/chefdk/bin/rubocop
lrwxr-xr-x 1 root wheel 20B Sep 15 13:34 shef -> /opt/chefdk/bin/shef
lrwxr-xr-x 1 root wheel 22B Sep 15 13:34 strain -> /opt/chefdk/bin/strain
lrwxr-xr-x 1 root wheel 24B Sep 15 13:34 strainer -> /opt/chefdk/bin/strainer
tcrowdermacmini:myface travis.crowder$

I am running OSX Mavericks and installed the ChefDK. I am following http://misheska.com/blog/2013/06/16/getting-started-writing-chef-cookbooks-the-berkshelf-way/#getting-started and ran into that error when doing vagrant up

@Spechal Are you using RVM? Using any Gemsets? Make sure you disable that stuff by using the system ruby when interacting with either the chef executable from the CLI or the Chef-DK directly or indirectly (aka. using vagrant-berkshelf)

Check which ruby you are using

$ which ruby

If the response is something that includes /usr/local/rvm or ~/.rvm then from the command line issue

$ rvm use system

And try to use vagrant-berkshelf again, you should have fewer problems with the system ruby.

I am using Ruby from Homebrew. I am not really sure how to fall back to the sytem ruby for just ChefDK; renaming embedded ruby and linking /usr/bin/ruby to embedded ruby? Seems hackish.

tcrowdermacmini:bin travis.crowder$ which ruby
/opt/chefdk/embedded/bin/ruby
tcrowdermacmini:bin travis.crowder$ pwd
/opt/chefdk/embedded/bin
tcrowdermacmini:bin travis.crowder$ ./ruby --version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]
tcrowdermacmini:bin travis.crowder$ /usr/bin/ruby --version
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
tcrowdermacmini:bin travis.crowder$

@Spechal what do you get for which berks if it's not the chefdk version, then that's what is causing the issue.

tcrowdermacmini:myface travis.crowder$ which berks
/opt/chefdk/embedded/bin/berks

I am working with two systems to try to get this going. Neither has Homebrew Ruby; I just installed RVM on one. The other will keep stock Mavericks Ruby. The stock Ruby/Mavericks has the config mentioned above.

On my fresh machine, system ruby, mavericks ... installed RVM, set RVM to use system, installed berkshelf gem, berks cookbook myface, vagrant up

traviss-mbp-2:myface tcrowder$ berks --version
r/Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/lib/ffi/library.rb:133:in `block in ffi_lib': Could not open library '/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_gecode.bundle': dlopen(/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_gecode.bundle, 5): Library not loaded: /private/var/folders/j6/qzmln98j1txgbs46qhzc05fm0000gn/T/bundler20140916-6949-bpvr6m/dep-selector-libgecode-1.0.2/gems/dep-selector-libgecode-1.0.2/lib/dep-selector-libgecode/vendored-gecode/lib/libgecodesearch.32.dylib (LoadError)
  Referenced from: /Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_gecode.bundle
  Reason: image not found
    from /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/lib/ffi/library.rb:100:in `map'
    from /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/lib/ffi/library.rb:100:in `ffi_lib'
    from /Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector/dep_gecode.rb:39:in `<module:Dep_gecode>'
    from /Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector/dep_gecode.rb:21:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector/gecode_wrapper.rb:21:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector/dependency_graph.rb:21:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector/selector.rb:21:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector.rb:22:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/solve-1.2.1/lib/solve/solver.rb:1:in `<top (required)>'
    from /Library/Ruby/Gems/2.0.0/gems/solve-1.2.1/lib/solve.rb:10:in `require_relative'
    from /Library/Ruby/Gems/2.0.0/gems/solve-1.2.1/lib/solve.rb:10:in `<module:Solve>'
    from /Library/Ruby/Gems/2.0.0/gems/solve-1.2.1/lib/solve.rb:3:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.1.5/lib/berkshelf.rb:8:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.1.5/lib/berkshelf/cli.rb:1:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.1.5/bin/berks:3:in `<top (required)>'
    from /opt/chefdk/bin/berks:23:in `load'
    from /opt/chefdk/bin/berks:23:in `<main>'
traviss-mbp-2:myface tcrowder$```

Aside from the conversation regarding ruby (ChefDk comes with its own
ruby), you do not install the berkshelf gem... rather, you should install
the "vagrant-berkshelf" vagrant plugin.

On Tue, Sep 16, 2014 at 11:30 AM, Travis Crowder notifications@github.com
wrote:

On my fresh machine, system ruby, mavericks ... installed RVM, set RVM to
use system, installed berkshelf gem, berks cookbook myface, vagrant up

traviss-mbp-2:myface tcrowder$ berks --version
r/Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/lib/ffi/library.rb:133:in block
in ffi_lib': Could not open library
'/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_gecode.bundle':
dlopen(/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_gecode.bundle,
5): Library not loaded:
/private/var/folders/j6/qzmln98j1txgbs46qhzc05fm0000gn/T/bundler20140916-6949-bpvr6m/dep-selector-libgecode-1.0.2/gems/dep-selector-libgecode-1.0.2/lib/dep-selector-libgecode/vendored-gecode/lib/libgecodesearch.32.dylib
(LoadError)
Referenced from:
/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_gecode.bundle
Reason: image not found
from /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/lib/ffi/library.rb:100:inmap'
from /Library/Ruby/Gems/2.0.0/gems/ffi-1.9.3/lib/ffi/library.rb[image:
💯]in ffi_lib'
from
/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector/dep_gecode.rb:39:in
module:Dep_gecode'
from
/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector/dep_gecode.rb:21:in
<top (required)>'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from
/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector/gecode_wrapper.rb:21:in
'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from
/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector/dependency_graph.rb:21:in
<top (required)>'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from
/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector/selector.rb:21:in
'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from
/Library/Ruby/Gems/2.0.0/gems/dep_selector-1.0.3/lib/dep_selector.rb:22:in <top
(required)>'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from /Library/Ruby/Gems/2.0.0/gems/solve-1.2.1/lib/solve/solver.rb:1:in'
from /Library/Ruby/Gems/2.0.0/gems/solve-1.2.1/lib/solve.rb:10:in
require_relative'
from /Library/Ruby/Gems/2.0.0/gems/solve-1.2.1/lib/solve.rb:10:in
module:Solve'
from /Library/Ruby/Gems/2.0.0/gems/solve-1.2.1/lib/solve.rb:3:in <top
(required)>'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.1.5/lib/berkshelf.rb:8:in'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in
require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in
require'
from
/Library/Ruby/Gems/2.0.0/gems/berkshelf-3.1.5/lib/berkshelf/cli.rb:1:in <top
(required)>'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in
require'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:73:in
require'
from /Library/Ruby/Gems/2.0.0/gems/berkshelf-3.1.5/bin/berks:3:in'
from /opt/chefdk/bin/berks:23:in load'
from /opt/chefdk/bin/berks:23:in'
traviss-mbp-2:myface tcrowder$


Reply to this email directly or view it on GitHub
#212 (comment)
.

Orin Fink, managing partner
P 312.340.6503 | C *312.933.3433 | *F 312.329.1963
15 West Hubbard Street, Suite 300 | Chicago, IL 60654

Ok, I will remove it ... http://misheska.com/blog/2013/06/16/getting-started-writing-chef-cookbooks-the-berkshelf-way/#getting-started needs updated for whoever runs it, if they are on this thread.

Bollox ...

tcrowdermacmini:bin travis.crowder$ sudo gem uninstall berkshelf
Password:

Select gem to uninstall:

  1. berkshelf-3.1.5
  2. berkshelf-3.1.5
  3. All versions

    3
    Remove executables:
    berks

in addition to the gem? [Yn] Y
Removing berks
Successfully uninstalled berkshelf-3.1.5
ERROR: While executing gem ... (NoMethodError)
undefined method `name' for nil:NilClass
tcrowdermacmini:bin travis.crowder$ vagrant plugin install vagrant-berkshelf
Installing the 'vagrant-berkshelf' plugin. This can take a few minutes...
Installed the plugin 'vagrant-berkshelf (3.0.1)'!
Post install message from the 'vagrant-berkshelf' plugin:

In order to use the Vagrant-Berkshelf plugin, you must have ChefDK installed.
To download the latest ChefDK visit http://getchef.com/downloads/chef-dk.

ChefDK is installed.

tcrowdermacmini:bin travis.crowder$ ls -alh /usr/bin | egrep "chef|berks"
lrwxr-xr-x 1 root wheel 21B Sep 15 13:34 berks -> /opt/chefdk/bin/berks
lrwxr-xr-x 1 root wheel 20B Sep 15 13:34 chef -> /opt/chefdk/bin/chef
lrwxr-xr-x 1 root wheel 26B Sep 15 13:34 chef-apply -> /opt/chefdk/bin/chef-apply
lrwxr-xr-x 1 root wheel 27B Sep 15 13:34 chef-client -> /opt/chefdk/bin/chef-client
lrwxr-xr-x 1 root wheel 26B Sep 15 13:34 chef-shell -> /opt/chefdk/bin/chef-shell
lrwxr-xr-x 1 root wheel 25B Sep 15 13:34 chef-solo -> /opt/chefdk/bin/chef-solo
lrwxr-xr-x 1 root wheel 25B Sep 15 13:34 chef-zero -> /opt/chefdk/bin/chef-zero
lrwxr-xr-x 1 root wheel 23B Sep 15 13:34 fauxhai -> /opt/chefdk/bin/fauxhai
lrwxr-xr-x 1 root wheel 26B Sep 15 13:34 foodcritic -> /opt/chefdk/bin/foodcritic
lrwxr-xr-x 1 root wheel 23B Sep 15 13:34 kitchen -> /opt/chefdk/bin/kitchen
lrwxr-xr-x 1 root wheel 21B Sep 15 13:34 knife -> /opt/chefdk/bin/knife
lrwxr-xr-x 1 root wheel 20B Sep 15 13:34 ohai -> /opt/chefdk/bin/ohai
lrwxr-xr-x 1 root wheel 23B Sep 15 13:34 rubocop -> /opt/chefdk/bin/rubocop
lrwxr-xr-x 1 root wheel 20B Sep 15 13:34 shef -> /opt/chefdk/bin/shef
lrwxr-xr-x 1 root wheel 22B Sep 15 13:34 strain -> /opt/chefdk/bin/strain
lrwxr-xr-x 1 root wheel 24B Sep 15 13:34 strainer -> /opt/chefdk/bin/strainer
tcrowdermacmini:bin travis.crowder$

Using the chruby/ruby-build environment detailed at Mischa Taylor's Coding Blog, what worked for me was installing ChefDK systemwide (AUR), uninstalling all berkshelf gems under ~/.rubies, and not actually using the chruby environment at all.

@rstrox a similar method worked for me; clean install, install chruby guided by blog post, install chefdk

I am using rvm and found the same error. In my case the problem seems that vagrant could not load berkshelf from its own gem repository. Had luck by using this:

vagrant plugin install berkshelf
vagrant plugin install vagrant-berkshelf

Okay, I work around this by deleting all gems folder in ~/vagrant.d/gems/gems and /path/to/vagrant/embedded/gems/gems and symlink it to /var/lib/gems/1.9.1/gems.

It worked beautifully.

As a note, I used Ubuntu 14.04 32 bit. ChefDK doesn't support 32 bit OS. But apparently I am still able to use berkshelf

Having the same issue on Windows 8.1 - ended up doing 'gem install berkshelf' and everything worked.

If you're using the auto-switching feature in chruby (I think others have them as well), note that it auto-mangles your $PATH when you switch app directories. I haven't found a permanent fix (I suspect I'll need to modify the auto.sh script), but re-mangling your path after you switch into your app's directory fixes this issue. Just export PATH="/opt/chefdk/bin:$PATH". I think @reset's $HOME stuff is a local setup for his stuff. The default install of ChefDK didn't instal anything into $HOME for me.

I recently had a similar issue so I decided to write it down so I don't forget it later http://alexfalkowski.blogspot.com.au/2014/10/configuring-chef-development-environment.html

@joestump I love chruby, but:

..it auto-mangles your $PATH when you switch app directories.

Yeaaaa. That's rather annoying and has bitten me a few times before.

I am not convinced this is a Berkshelf or Vagrant Berkshelf issue, but rather an issue with $PATHing and $PATH ordering. The path to ChefDK's bin directory must be first in your path in order for Vagrant Berkshelf to find Berkshelf. It goes like this:

  1. Vagrant (which has an entirely different Ruby environment) starts
  2. Vagrant Berkshelf (which you installed into Vagrant's Ruby environment) shells out to berks
  3. When shelling out, berks must be resolved to the Berkshelf executable bundled in ChefDK

So, recommended debugging steps:

  • Run which berks. If the output is anything other than ($CHEFDK)/bin/berks, you likely have the Berkshelf gem installed on your system. Remove all instances of Berkshelf that are not part of the ChefDK.
  • If which berks returns the path to Berkshelf in the ChefDK, it's possible you having a plugin that is modifying the path each time a new shell is loaded (like chruby). In this instance, you will need to do some research to 1. disable this functionality or 2. use a solution like suggested by @joestump's 😄.

NOT recommended solutions:

  • Do not touch anything in ~/.vagrant.d/gems
  • Do not touch anything in ($CHEFDK)/{gems, bin, etc}

If you start creating symlinks and moving files around inside of Vagrant and/or ChefDK, you risk ruining the upgrade path or breaking things beyond repair.

I have faced this issue to. I have installed on my Mac OS x 10.9:

  • rvm
  • chef(workstation, client)
  • chefdk
  • standard Mac system Ruby

Steps that I performed to resolve this issue:

  • Remove Chefdk( according to https://docs.chef.io/install_dk.html)
  • I have removed all chef, berkshelf and librarian gem via: sudo gem uninstall
  • I have downloaded & installed ChefDK and it works again

@joestump 's solution worked for me.

export PATH="/opt/chefdk/bin:$PATH"

In the meantime my temporary solution is to sandbox the PATH in my project until I can sort this out.
BTW, I'm using rbenv on Mac OS X Yosemite.

Same as @pedrocarrico , @joestump 's solution worked for me on a MacBookPro11,1 with OS X Yosemite 10.10.2 installed.

export PATH="/opt/chefdk/bin:$PATH"

I got the same error:

Monas-MacBook-Pro:~ mona$ chef --v
Chef Development Kit Version: 0.15.16
chef-client version: 12.11.18
delivery version: master (444effdf9c81908795e88157f01cd667a6c43b5f)
berks version: ERROR
kitchen version: 1.10.0
Monas-MacBook-Pro:~ mona$ sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.10.5
BuildVersion:   14F1713

After I changed the bashrc to what @ursachec told it worked for me:

Monas-MacBook-Pro:~ mona$ vi ~/.bashrc
Monas-MacBook-Pro:~ mona$ source ~/.bashrc
nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local"
Run `npm config delete prefix` or `nvm use --delete-prefix v4.0.0 --silent` to unset it.
Monas-MacBook-Pro:~ mona$ chef --v
Chef Development Kit Version: 0.15.16
chef-client version: 12.11.18
delivery version: master (444effdf9c81908795e88157f01cd667a6c43b5f)
berks version: 4.3.5
kitchen version: 1.10.0

I added this line in bashrc: export PATH="/opt/chefdk/bin:$PATH"

I don't use RVM anymore but I was never able to get it to play nicely with ChefDK when I last played with it. That's why I wrote the rbenv-chefdk plugin mentioned above.