Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jsmartt opened this issue Jan 15, 2015 · 16 comments

Comments

@jsmartt
Copy link

jsmartt commented Jan 15, 2015

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
Copy link

cbreden commented Jan 21, 2015

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
Copy link

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

@spifrancisv
Copy link

Seeing this issue on Windows 8.1 and Vagrant 1.7.2

@miguelaferreira
Copy link
Contributor

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:

pid = %x[ lsof -i tcp:#{port} | grep -E 'ruby|chef-zero' | awk '{print $2}' ]

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
Copy link
Contributor

ping @electrofelix

Do you have any input regarding this issue?

@miguelaferreira
Copy link
Contributor

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
Copy link

$ 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
Copy link

ctrl78 commented Jun 2, 2015

Hi ,
Same issue for me and same versions

@cbreden
Copy link

cbreden commented Jun 2, 2015

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
Copy link
Contributor

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

@electrofelix
Copy link
Contributor

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
Copy link

cbreden commented Jun 2, 2015

That's a good find!

C:\>ruby -e "p RbConfig::CONFIG['host_os']"
"mingw32"

@miguelaferreira
Copy link
Contributor

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
Copy link

ctrl78 commented Jun 3, 2015

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)

  • Version Constraint: 1.0.1
    vagrant-omnibus (1.4.1)
    vagrant-share (1.1.3, system)
    vagrant-vbguest (0.10.0)

@miguelaferreira
Copy link
Contributor

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
Copy link
Contributor

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

@j00p34 j00p34 closed this as completed in #73 Jun 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants