Vagrant: LoadError when attempting to run plugins that depend on nokogiri

Created on 30 Dec 2015  路  14Comments  路  Source: hashicorp/vagrant

This appears to be due to the fact that nokogiri added Windows/Ruby 2.2 support starting with version 1.6.7 (see https://github.com/sparklemotion/nokogiri/issues/1256); the latest releases of vagrant embed Ruby 2.2.3, yet pin nokogiri at version 1.6.3.1 (see https://github.com/mitchellh/vagrant/blob/master/vagrant.gemspec#L35)

As a result, any attempt to run a plugin that depends on nokogiri (including vagrant-aws) runs into a LoadError:

> vagrant up --provider=aws
C:/HashiCorp/Vagrant/embedded/gems/gems/nokogiri-1.6.3.1-x86-mingw32/lib/nokogiri.rb:29:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
        from C:/HashiCorp/Vagrant/embedded/gems/gems/nokogiri-1.6.3.1-x86-mingw32/lib/nokogiri.rb:29:in `rescue in <top (required)>'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/nokogiri-1.6.3.1-x86-mingw32/lib/nokogiri.rb:25:in `<top (required)>'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/fog-xml-0.1.2/lib/fog/xml.rb:2:in `require'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/fog-xml-0.1.2/lib/fog/xml.rb:2:in `<top (required)>'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/fog-1.37.0/lib/fog.rb:13:in `require'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/fog-1.37.0/lib/fog.rb:13:in `<top (required)>'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/vagrant-aws-0.6.0/lib/vagrant-aws/action/connect_aws.rb:1:in `require'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/vagrant-aws-0.6.0/lib/vagrant-aws/action/connect_aws.rb:1:in `<top (required)>'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/vagrant-aws-0.6.0/lib/vagrant-aws/action.rb:98:in `block in action_read_state'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/vagrant-aws-0.6.0/lib/vagrant-aws/action.rb:96:in `tap'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/vagrant-aws-0.6.0/lib/vagrant-aws/action.rb:96:in `action_read_state'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/vagrant-aws-0.6.0/lib/vagrant-aws/provider.rb:16:in `action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:187:in `block in action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:561:in `lock'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:185:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:185:in `action'
        from C:/Users/rafael_goodman/.vagrant.d/gems/gems/vagrant-aws-0.6.0/lib/vagrant-aws/provider.rb:32:in `state'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:501:in `state'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:144:in `initialize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/vagrantfile.rb:79:in `new'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/vagrantfile.rb:79:in `machine'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:663:in `machine'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/plugin/v2/command.rb:177:in `block in with_target_vms'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/plugin/v2/command.rb:201:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/plugin/v2/command.rb:201:in `block in with_target_vms'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/plugin/v2/command.rb:183:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/plugin/v2/command.rb:183:in `with_target_vms'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/commands/up/command.rb:89:in `block in execute'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:278:in `block (2 levels) in batch'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:276:in `tap'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:276:in `block in batch'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:275:in `synchronize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:275:in `batch'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/commands/up/command.rb:88:in `execute'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/cli.rb:42:in `execute'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:302:in `cli'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.1/bin/vagrant:174:in `<main>'
bug core has-pr installer

All 14 comments

I am having this issue as well using the vagrant-vsphere provider

I'm having the same problem after upgrading to Vagrant 1.8.1. I updated to solve the rsync problem in Windows.
I tried installing ruby separately, and then installing nokogiri using gem, but still doesn't work.
Any work around for this?

I edited the vagrant.gemspec and vagrant-1.8.1.gemspec
files and changed the nokogiri dependency settings in several places to ">= 1.6.3.1", then ran:

vagrant plugin install nokogiri --plugin-version 1.6.7.1.

Also, remove these lines (77-79) from
Vagrant\embedded\gems\gems\vagrant-1.8.1\plugins\synced_folders\rsync\helper.rb

      "-o ControlMaster=auto " +
      "-o ControlPath=#{controlpath} " +
      "-o ControlPersist=10m " +

I also added HOME = %USERPROFILE% to my environment. Also, you have to be sure that the rsync tool and the ssh tool come from the same set. I had an incompatible rsync in my path before the msys version and had to move msys earlier in the path chain. Use "where rsync" and "where ssh" to check.

Thanks a lot @dnadle for the quick answer. I have modified the two files C:\HashiCorp\Vagrant\embedded\gems\specifications\vagrant-1.8.1.gemspec and C:\HashiCorp\Vagrant\embedded\gems\specifications\vagrant.gemspec, updating the nokogiri version for "=> 1.6.3.1". That solved the problem with nokogiri.
However, I still have the problem with rsync. Even after commenting the lines you indicated, added a HOME variable to my user, and placed rsync and ssh in the same folder.

I'm using mingw64

$ which rsync
/usr/bin/rsync

$ which ssh
/usr/bin/ssh

$ rsync --version
rsync  version 3.1.2  protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, no xattrs, iconv, symtimes, prealloc

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

$ vagrant reload
==> default: Stopping the instance...
==> default: Warning! The AWS provider doesn't support any of the Vagrant
==> default: high-level network configurations (`config.vm.network`). They
==> default: will be silently ignored.
==> default: Starting the instance...
==> default: Waiting for instance to become "ready"...
==> default: Waiting for SSH to become available...
==> default: Machine is booted and ready for use!
==> default: Rsyncing folder: /c/projects/vagrant-machines/dummy-aws-test/ogdobs/ => /home/ubuntu/ogdobs
==> default:   - Exclude: [".vagrant/", ".git/"]
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /c/projects/vagrant-machines/dummy-aws-test/ogdobs/
Guest path: /home/ubuntu/ogdobs
Command: rsync --verbose --archive --delete -z --copy-links --chmod=ugo=rwX --no-perms --no-owner --no-group --rsync-path sudo rsync -e ssh -p 22 -o StrictHostKeyChecking=no -o IdentitiesOnly=true -o UserKnownHostsFile=/dev/null -i 'PATH_TO_MY_KEY' --exclude .vagrant/ --exclude .git/ /c/projects/vagrant-machines/dummy-aws-test/ogdobs/ ubuntu@AWS_MACHINE:/home/ubuntu/ogdobs
Error: Warning: Permanently added 'AWS_MACHINE' (ECDSA) to the list of known hosts.
dup() in/out/err failed
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.2]

That looks like an incompatible rsync. I'm having success with version 3.0.8 protocol version 30, and an Amazon Linux instance. You might try a different AMI to see if there's an issue with Ubuntu.

I would also try uncommenting the lines in helper.rb with your rsync and Ubuntu. Maybe those lines work with that version...

Please move Rsync discussion to #6702. This is an issue about nokogiri version conflict.

When will 1.8.2. be released?

How can this be closed when it is still broken?

I just reinstalled it clean and still have the same error.

This is happening for me as well.

Welcome to the world of open source, jb11211.

Here are the steps I took to get it working.
The steps above about editing the files are part of the solution:

.\HashiCorp\Vagrant\embedded\gems\specifications\vagrant-1.8.1.gemspec and .\HashiCorp\Vagrant\embedded\gems\specifications\vagrant.gemspec
find and replace "=1.6.3.1" with ">=1.6.7.2"

Next: run
gem install nokogiri (there may be a better way to get this, but I am new to this).
find the '.gemspec' files for nokogiri-1.6.7.x and mini_portile2-2.x
copy them to
.\HashiCorp\Vagrant\embedded\gems\specifications

Restart your environment or just reboot.

vagrant up will install the versions needed.

I hope I remembered all the steps. There was a lot of trial and error.

@wyzerd fun stuff!

I guess I better shut up because I got vagrant for free...but here's hoping somebody will address this issue 6 month old problem.

edit: I also had to install gem because well, I guess somebody decided early on ruby is so popular and everyone else should follow it.

edit: looks like can't install nokogiri with ruby 2.3. will need to uninstall it and use something lower I guess.

edit: okay finished uninstalling, downloaded ruby 2.1 and installed it.

edit: gem install nokogiri fails once more! apparently it needs installed build tools...looks like I need to follow further instructions provided in the url. I'm having a blast you guys!

edit: okay extracted devkit, read https://github.com/oneclick/rubyinstaller/wiki/Development-Kit to install it. looks like its now able to compile stuff that ruby gem needs.

edit: well looks like its taking a while to build native extensions. eagerly awaiting.

edit: wow this is taking quite some time. I had no idea a ruby parser with xpath support could take longer than downloading the entire season of Better Call Saul (such a great show). Hanging in there! I just love Ruby!

edit: Hooray! After 15 minutes of CPU fan spinning hard it succesfully installed nokogiri! Now to follow rest of @wyzerd's instructions. It's not over yet!

edit: oh I don't know where ruby gems are installed. Guess I will need to consult google.

edit: and .gemspec is not in the nokogiri 1.6.7 gem directory. Instead, there's a markdown file with what appears to be a wordy and rant explaining why it isn't there written in a passive aggressive tone. I'm not quite keen on reading it nor do I understand any of what's written as I'm not a ruby power user.

edit: following wyzerds instructions yields a non solution. I guess I've been bamboozled.

Well, looks like this is a non functioning plugin on windows. Maybe if I used vagrant inside vagrant? Nah, seems like the time I spent trying to get this plugin running I could've just setup an Autoscaling CloudFormation template instead in the hour it took to get this far.

Well we now know why this issue has been open for so long!

edit: oh silly me issue has been CLOSED yet it still remains. I guess this is what people do on poorly maintained and subpar quality open source projects. CLOSE a broken issue that you won't fix and not respond. Professional and reflects greatly on your CV!

mnko, sorry it didn't work out for you. nokogiri was the only part that was giving me problems and that was a month ago. I don't even remember the pain I went through (psychological block)... I wish I knew more about it, but like I said, I am new to this.

This has been fixed but there hasn't been a new release that includes the fix. I used the vagrant-installers project to build my own msi for vagrant and it wasn't too painful. If you are running on Windows I posted what worked for me here: build your own 1.8.2

Was this page helpful?
0 / 5 - 0 ratings