schubergphilis / vagrant-chef-zero

Vagrant Plugin for Chef Zero
Apache License 2.0
91 stars 42 forks source link

ffi-yajl and yajl-ruby gems have incompatible C libyajl libs... cannot load such file -- ruby-wmi #63

Closed jsmartt closed 9 years ago

jsmartt commented 9 years ago

After installing vagrant-chef-zero on my Windows 7 machine, vagrant is no longer able to create VMs, even when the chef-zero provisioner is not used. Here's the error I got:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
the ffi-yajl and yajl-ruby gems have incompatible C libyajl libs and should not be loaded in the same Ruby VM
falling back to ffi which might work (or might not, no promises)
C:/Users/smartt/.vagrant.d/gems/gems/chef-11.6.0/lib/chef/provider/env/windows.rb:20:in `require': cannot load such file -- ruby-wmi (LoadEr
ror)
        from C:/Users/smartt/.vagrant.d/gems/gems/chef-11.6.0/lib/chef/provider/env/windows.rb:20:in `<top (required)>'
        from C:/Users/smartt/.vagrant.d/gems/gems/chef-11.6.0/lib/chef/providers.rb:51:in `require'
        from C:/Users/smartt/.vagrant.d/gems/gems/chef-11.6.0/lib/chef/providers.rb:51:in `<top (required)>'
        from C:/Users/smartt/.vagrant.d/gems/gems/chef-11.6.0/lib/chef.rb:25:in `require'
        from C:/Users/smartt/.vagrant.d/gems/gems/chef-11.6.0/lib/chef.rb:25:in `<top (required)>'
        from C:/Users/smartt/.vagrant.d/gems/gems/vagrant-chef-zero-0.7.1/lib/vagrant-chef-zero/action/upload.rb:1:in `require'
        from C:/Users/smartt/.vagrant.d/gems/gems/vagrant-chef-zero-0.7.1/lib/vagrant-chef-zero/action/upload.rb:1:in `<top (required)>'
        from C:/Users/smartt/.vagrant.d/gems/gems/vagrant-chef-zero-0.7.1/lib/vagrant-chef-zero/action.rb:19:in `block in chef_zero_provisio
n'
        from C:/Users/smartt/.vagrant.d/gems/gems/vagrant-chef-zero-0.7.1/lib/vagrant-chef-zero/action.rb:17:in `tap'
        from C:/Users/smartt/.vagrant.d/gems/gems/vagrant-chef-zero-0.7.1/lib/vagrant-chef-zero/action.rb:17:in `chef_zero_provision'
        from C:/Users/smartt/.vagrant.d/gems/gems/vagrant-chef-zero-0.7.1/lib/vagrant-chef-zero/plugin.rb:20:in `provision'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:42:in `call'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:42:in `block (2 levels) in run'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:41:in `tap'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:41:in `block in run'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:40:in `map'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/runner.rb:40:in `run'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:214:in `action_raw'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:191:in `block in action'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:516:in `lock'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in `call'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:178:in `action'
        from c:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'

Vagrant Plugins:

$ vagrant plugin list
  vagrant-berkshelf (3.0.1)
    - Version Constraint: 3.0.1
  vagrant-chef-zero (0.7.1)
  vagrant-omnibus (1.4.1)
  vagrant-proxyconf (1.4.0)
  vagrant-share (1.1.3)
  vagrant-vbguest (0.10.0)

Relevant gems:

$ gem list | grep 'yajl\|ffi\|wmi\|chef\|vagrant'
  chef (12.0.0.rc.0 x86-mingw32, 11.18.0.rc.1 x86-mingw32, 11.16.4 x86-mingw32, 11.6.0, 10.34.4 x86-mingw32, 0.8.10)
  chef-dk (0.3.5)
  chef-provisioning (0.16.1)
  chef-provisioning-aws (0.1.1)
  chef-provisioning-azure (0.1)
  chef-provisioning-fog (0.11)
  chef-provisioning-vagrant (0.8.1)
  chef-vault (2.2.4)
  chef-zero (3.2, 2.2.1, 1.5.6)
  cheffish (0.9)
  chefspec (4.2.0.beta.1)
  ffi (1.9.6 x86-mingw32, 1.3.1 x86-mingw32)
  ffi-yajl (1.2.0)
  kitchen-vagrant (0.15.0)
  libyajl2 (1.1.0)
  rdp-ruby-wmi (0.3.1)
  wmi-lite (1.0.0)
  yajl-ruby (1.2.1)

Then I uninstall the vagrant-chef-zero plugin and it runs fine. Before uninstalling the plugin, I also tried updating the relevant gems, using older versions of libyajl, yajl-ruby, and ffi-yajl. I even tried uninstalling chefdk and all the gems, then reinstalling a clean version, but no luck.

cbreden commented 9 years ago

I am also getting this, with the same thing after a clean install.

C:\Users\cbreden\Documents\vagrant\c-vbox1\the_commons>vagrant -v
Vagrant 1.7.2

C:\Users\cbreden\Documents\vagrant\c-vbox1\the_commons>vagrant plugin list
vagrant-berkshelf (4.0.2)
vagrant-chef-zero (0.7.1)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.4, system)
vagrant-vcenter (0.3.2)

C:\Users\cbreden\Documents\vagrant\c-vbox1\the_commons>vagrant up
Bringing machine 'cbreden-chef1' up with 'virtualbox' provider...
the ffi-yajl and yajl-ruby gems have incompatible C libyajl libs and should not be loaded in the same Ruby VM
falling back to ffi which might work (or might not, no promises)
C:/Users/cbreden/.vagrant.d/gems/gems/chef-11.6.0/lib/chef/provider/env/windows.rb:20:in `require': cannot load such file -- ruby-wmi (LoadError)
        from C:/Users/cbreden/.vagrant.d/gems/gems/chef-11.6.0/lib/chef/provider/env/windows.rb:20:in `<top (required)>'
        from C:/Users/cbreden/.vagrant.d/gems/gems/chef-11.6.0/lib/chef/providers.rb:51:in `require'
        from C:/Users/cbreden/.vagrant.d/gems/gems/chef-11.6.0/lib/chef/providers.rb:51:in `<top (required)>'
        ...

I tried to shoe-in ruby-wmi to both gem directories like so:

cmd /C "set GEM_HOME=C:/Users/cbreden/.vagrant.d/gems&& C:\HashiCorp\Vagrant\embedded\bin\gem install ruby-wmi --no-ri --no-rdoc"
cmd /C "set GEM_HOME=C:/HashiCorp/Vagrant/embedded/gems&& C:\HashiCorp\Vagrant\embedded\bin\gem install ruby-wmi --no-ri --no-rdoc"

...but to no avail. I'm scouting for some specific configuration file somewhere that is preventing ruby-wmi from being loaded, but haven't found anything yet.

joelwilson commented 9 years ago

For what it's worth, I am also seeing this problem on Windows 7. Vagrant 1.6.5.

spifrancisv commented 9 years ago

Seeing this issue on Windows 8.1 and Vagrant 1.7.2

miguelaferreira commented 9 years ago

I never used it on windows, but a colleague of mine who did told me that the plugin makes use of the lsof tool to find the process id of chef-zero. AFAIK lsof a unix/linux tool and it is not available on Windows. It is used here: https://github.com/schubergphilis/vagrant-chef-zero/blob/f635cf5084ebc650605f7c5924ec1e70f612741e/lib/vagrant-chef-zero/server_helpers.rb#L124

Now regarding the error @jsmartt posted, it seems the vagrant environment is missing a gem called ruby-wmi. I would expect that vagrant install would pull that in. That should be required to run the plugin on windows, the strange thing is that it was not installed.

The gem install command posted by @cbreden should have installed it. @cbreden could you please post the output of:

C:\HashiCorp\Vagrant\embedded\bin\gem list
miguelaferreira commented 9 years ago

ping @electrofelix

Do you have any input regarding this issue?

miguelaferreira commented 9 years ago

BTW: from the posts of @jsmartt @cbreden you both seem to be running an old version of the plugin. The latest version is v1.0.1

@joelwilson @spifrancisv What versions are you using?

spifrancisv commented 9 years ago
$ vagrant plugin list
vagrant-berkshelf (4.0.4)
vagrant-chef-zero (1.0.1)
vagrant-hostmanager (1.5.0)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.3, system)
vagrant-vbguest (0.10.0)
ctrl78 commented 9 years ago

Hi , Same issue for me and same versions

cbreden commented 9 years ago

Upgraded to 1.0.1 but still have the same issue:

C:\Users\cbreden\Documents\vagrant\c-vbox1\the_commons>vagrant -v
Vagrant 1.7.2

C:\Users\cbreden\Documents\vagrant\c-vbox1\the_commons>vagrant plugin list
vagrant-berkshelf (4.0.4)
vagrant-chef-zero (1.0.1)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.4, system)
vagrant-vcenter (0.3.2)

C:\Users\cbreden\Documents\vagrant\c-vbox1\the_commons>C:\HashiCorp\Vagrant\embedded\bin\gem list

*** LOCAL GEMS ***

bigdecimal (1.2.0)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
ruby-wmi (0.4.0)
test-unit (2.0.0.0)
miguelaferreira commented 9 years ago

Thanks everyone. I will look into this ASAP (that means probably tomorrow otherwise the day after).

electrofelix commented 9 years ago

I believe that there is a second gem required on Windows. I can only assume the following piece of code is not getting properly executed in this case.

# Windows platform requirements to run chef-zero
platforms :mswin, :mingw do
  gem "ruby-wmi"
  gem "win32-service"
end

The list of platforms may not be sufficient, it may be necessary to tweak the list.

Suggest running the following on the system missing the gems.

ruby -e "p RbConfig::CONFIG['host_os']"

May need to go through the various options suggested on http://stackoverflow.com/a/8699106/1597808 to see which gives sensible result.

cbreden commented 9 years ago

That's a good find!

C:\>ruby -e "p RbConfig::CONFIG['host_os']"
"mingw32"
miguelaferreira commented 9 years ago

Indeed adding :mingw32 to the Gemfile fixes it for me on Windows 2012 R2.

I will add this to the Gemfile in the repo (via PR), and you guys can install the plugin from source to test:

git clone https://github.com/miguelaferreira/vagrant-chef-zero.git
git checkout -b fix-windows-gem-build origin/fix-windows-gem-build
cd vagrant-chef-zero
gem build .\vagrant-chef-zero.gemspec
vagrant plugin install .\vagrant-chef-zero-1.0.1.gem

Let me know how it works out.

ctrl78 commented 9 years ago

Well done it's working perfectly for me PS: 06/03/2015 16:46:03>vagrant plugin list
vagrant-berkshelf (4.0.4)
vagrant-chef-zero (1.0.1)

miguelaferreira commented 9 years ago

It is now broken on non-windows platforms https://travis-ci.org/schubergphilis/vagrant-chef-zero/builds/65252216

Will work on that before having thePR #73 merged

miguelaferreira commented 9 years ago

Travis is happy again, we can proceed with merging. https://travis-ci.org/schubergphilis/vagrant-chef-zero/builds/65365063