berkshelf / vagrant-berkshelf

A Vagrant plugin to add Berkshelf integration to the Chef provisioners
Other
378 stars 100 forks source link

Could not determine Berks version. v3.0.0 #212

Closed dkinzer closed 10 years ago

dkinzer commented 10 years ago
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               
sethvargo commented 10 years ago

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

dkinzer commented 10 years ago

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

dkinzer commented 10 years ago

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

dkinzer commented 10 years ago

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

paulczar commented 10 years ago

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

dkinzer commented 10 years ago

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?
dkinzer commented 10 years ago

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.

reset commented 10 years ago

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

dkinzer commented 10 years ago

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

reset commented 10 years ago

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

rchekaluk commented 10 years ago

@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...

reset commented 10 years ago

@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

hschaeidt commented 10 years ago

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?

reset commented 10 years ago

@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.

zarry commented 10 years ago

@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 ✗)]$
hschaeidt commented 10 years ago

@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?

zarry commented 10 years ago

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

dkinzer commented 10 years ago

@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]
zarry commented 10 years ago

@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...

dkinzer commented 10 years ago

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

dkinzer commented 10 years ago

@zarry I reopened this issue on your behalf.

reset commented 10 years ago

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!

zarry commented 10 years ago

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.

cmalek commented 10 years ago

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?

cmalek commented 10 years ago

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.

reset commented 10 years ago

@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.

cmalek commented 10 years ago

@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.

reset commented 10 years ago

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

robsonpeixoto commented 10 years ago

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)
dkinzer commented 10 years ago

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?

sethvargo commented 10 years ago

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.

hschaeidt commented 10 years ago

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.

cmalek commented 10 years ago

@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.

zarry commented 10 years ago

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

reset commented 10 years ago

@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.

johntdyer commented 10 years ago

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)
cmalek commented 10 years ago

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.

cmluciano commented 10 years ago

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.

misheska commented 10 years ago

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/

zarry commented 10 years ago

@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.

cmalek commented 10 years ago

@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.

zarry commented 10 years ago

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.

john5223 commented 10 years ago

To reiterate, fix for this is

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

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

cmalek commented 10 years ago

@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.

mattimatti commented 10 years ago

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.

cmluciano commented 10 years ago

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.

docwhat commented 10 years ago

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.

dpehrson commented 10 years ago

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

dividedmind commented 10 years ago

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.

dpehrson commented 10 years ago

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:

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.