hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.

Home Page:https://www.vagrantup.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to install plugins that depend on nokogiri in Vagrant 1.6+

lox opened this issue · comments

Since installing Vagrant 1.6.0, I'm unable to install landrush, or other plugins that depend on nokogiri:

I initially thought this was a landrush issue, but have reproduced with other vagrant plugins:

vagrant-landrush/landrush#69

I tested 1.6.1 and 1.6.2, both of which fail the same way. Reverting to 1.5.4 fixes the problem.

Could you share the logs? The underlying installer foundation didn't change at all between 1.5 and 1.6, which makes this odd.

Which logs shall I include? The landrush bug has a trace of the output. It's certainly strange, in that I'm sure it's been working fine for several days, but suddenly today our CI system and my own installation started to have the same issue. Entirely possible it's a bug elsewhere.

I have same error with "vagrant plugin update" command.

Error log:

Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.2), and Bundler cannot continue.
Make sure that gem install nokogiri -v '1.6.2' succeeds before bundling.

Same issue here:

$ vagrant --version
Vagrant 1.6.2

$ vagrant plugin list
vagrant-login (1.0.1, system)
vagrant-share (1.0.1, system)
vagrant-vmware-fusion (2.4.1)

$ vagrant plugin update vagrant-vmware-fusion
Updating plugins: vagrant-vmware-fusion. This may take a few minutes...
Building nokogiri using packaged libraries.
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2'` succeeds before bundling.

I run into this as well with vagrant 1.6.0, 1.6.1 and 1.6.2.
Downgrading to 1.5.4 helps (but well..not really ;-))

$ vagrant plugin install vagrant-omnibus
Installing the 'vagrant-omnibus' plugin. This can take a few minutes...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
    - 0001-Fix-parser-local-buffers-size-problems.patch
    - 0002-Fix-entities-local-buffers-size-problems.patch
    - 0003-Fix-an-error-in-previous-commit.patch
    - 0004-Fix-potential-out-of-bound-access.patch
    - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
    - 0006-Do-not-fetch-external-parsed-entities.patch
    - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
    - 0008-Improve-handling-of-xmlStopParser.patch
    - 0009-Fix-a-couple-of-return-without-value.patch
    - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
    - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Building libxslt-1.1.28 for nokogiri with the following patches applied:
    - 0001-Adding-doc-update-related-to-1.1.28.patch
    - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
    - 0003-Initialize-pseudo-random-number-generator-with-curre.patch
    - 0004-EXSLT-function-str-replace-is-broken-as-is.patch
    - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch
    - 0007-Separate-function-for-predicate-matching-in-patterns.patch
    - 0008-Fix-direct-pattern-matching.patch
    - 0009-Fix-certain-patterns-with-predicates.patch
    - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch
    - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
    - 0014-Fix-for-bug-436589.patch
    - 0015-Fix-mkdir-for-mingw.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxslt.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install
************************************************************************
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2'` succeeds before bundling.

The same problem:

$ rm -rf ~/.vagrant.d
$ vagrant plugin update
Updating installed plugins...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
    - 0001-Fix-parser-local-buffers-size-problems.patch
    - 0002-Fix-entities-local-buffers-size-problems.patch
    - 0003-Fix-an-error-in-previous-commit.patch
    - 0004-Fix-potential-out-of-bound-access.patch
    - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
    - 0006-Do-not-fetch-external-parsed-entities.patch
    - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
    - 0008-Improve-handling-of-xmlStopParser.patch
    - 0009-Fix-a-couple-of-return-without-value.patch
    - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
    - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2'` succeeds before bundling.

FYI: this might be caused by the recent upgrade of the nokogiri gem to 1.6.2
A quick workaround would be to pin the nokogiri gem version.
Unfortunately I don't know where the gem is required/bundled by vagrant :-/

Quick fix: add s.add_dependency(%q<nokogiri>, ["< 1.6.2"]) to ~/Applications/Vagrant/embedded/gems/specifications/vagrant-1.6.2.gemspec

Installing nokogiri gem with system installed libxml2 is temporal solution for this issue.

  1. Install libxml2 to system.
  2. Run export NOKOGIRI_USE_SYSTEM_LIBRARIES=true.
  3. Then try vagrant plugin update.

I've seen this happen when installing a pre-release version of vagrant-lxc and a user has just reported it as well.

Funny fact is that vagrant-lxc has no gem dependencies at all oO

Yep, I'm seeing this issue as well when attempting to install vmware_fusion /cc @josegonzalez

Confirmed that a downgrade works, though the export trick doesn't, and the s.add_dependency method doesn't work if you've deleted your .vagrant.d directory.

And now attempting to install vagrant-berkshelf in 1.5.4 also gives me the same error...

Ah, I wonder if this is caused by 1.6 adding the vagrant-windows dependencies which have a Nokogiri aspect.

I'm hitting this issue as well with vagrant-cachier, vagrant-omnibus, AND vagrant-hostsupdater

Downgrading to 1.5.4 doesn't work for me. After the downgrade when running vagrant plugin install vagrant-aws I still get the:

An error occurred while installing nokogiri (1.6.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2'` succeeds before bundling.

Is there another version you guys downgraded to? Also how do you delete the current installation, by just deleting the /Applications/Vagrant directory and the /usr/bin/vagrant binary?

After downgrading to 1.5.4 all my plugin reinstalls were working, except berkshelf. It was giving me that nokogiri error. It ended up working fine when I explicitly declared the plugin version in the install command:

This:

$ vagrant plugin install vagrant-berkshelf --plugin-version '>=2.0.1'

Not this:

$ vagrant plugin install vagrant-berkshelf

Maybe that will help you with vagrant-aws… or maybe not.

I believe this is actually caused by a recent Nokogiri update. Our build servers have recently failed to even build the Vagrant installers anymore because of this issue. I'll attempt to find a workaround.

Same problem here on a fresh Debian 7.5 install with Vagrant 1.6.2, trying to install vagrant-lxc

It works now on my machine with the last Nokogiri update v1.6.2.1.

1.6.2.1 / 2014-05-13

Bug fixes

Fix statically-linked libxml2 installation when using universal builds of Ruby. sparklemotion/nokogiri#1104

Patching mini_portile to address the git dependency detailed in sparklemotion/nokogiri#1102

Library load fix to address segfault reported on some systems. sparklemotion/nokogiri#1097

Fixed for me too. I think this was a Nokogiri bug.

Another 👍

I find it a bit suboptimal that nokogiri (or other core dependencies) gets upgraded even if the plugin doesn't have any dependency on it. But maybe there's no easy and safe way around it with Bundler?

@tmatilai Yeah I agree, not at the moment. I've been thinking of some optimizatoins around Bundler but I don't think what I'm thinking would fix this issue.

I've just upgraded to Vagrant 1.6.2 and ran into the same issue with nokogiri 1.6.2.1. I am able to manually install nokogiri 1.6.2.1 successfully on my OS X laptop, but vagrant fails with

Updating installed plugins...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
    - 0001-Fix-parser-local-buffers-size-problems.patch
    - 0002-Fix-entities-local-buffers-size-problems.patch
    - 0003-Fix-an-error-in-previous-commit.patch
    - 0004-Fix-potential-out-of-bound-access.patch
    - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
    - 0006-Do-not-fetch-external-parsed-entities.patch
    - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
    - 0008-Improve-handling-of-xmlStopParser.patch
    - 0009-Fix-a-couple-of-return-without-value.patch
    - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
    - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.

Will check to see if any of the workarounds work.

@geauxvirtual I have the same issue on a system where the command line tools are not installed. I do have Xcode 5.1.1 installed.

$ vagrant plugin update vagrant-vmware-fusion
Updating plugins: vagrant-vmware-fusion. This may take a few minutes...
Building nokogiri using packaged libraries.
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.

Unfortunately, the problem still appear on a fresh Debian 7.5 fresh install and on an Ubuntu 14.04 fresh install as well:

$ vagrant plugin install vagrant-lxc --plugin-version 1.0.0.alpha.2
Installing the 'vagrant-lxc --version '1.0.0.alpha.2'' plugin. This can take a few minutes...
Building nokogiri using packaged libraries.
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.

The quick fix from arosenhagen worked for me on OSX 10.8.5

Quick fix: add s.add_dependency(%q, ["< 1.6.2"]) to ~/Applications/Vagrant/embedded/gems/specifications/vagrant-1.6.2.gemspec

@nodje I had the same issue with a fresh installed ubuntu server 12.04. I also had installed libxml2 and libxslt as say in http://nokogiri.org/tutorials/installing_nokogiri.html

sudo apt-get install libxslt-dev libxml2-dev

When I checked the gem install command I got:

sudo /opt/vagrant/embedded/bin/gem install nokogiri -v '1.6.2.1'
...
libiconv is missing. please visit…
...

Also tried give all lib paths:

sudo /opt/vagrant/embedded/bin/gem install nokogiri -v '1.6.2.1' -- --with-xml2-lib=/usr/lib/x86_64-linux-gnu --with-xml2-include=/usr/include/libxml2 --with-xslt-lib=/usr/lib/x86_64-linux-gnu --with-xslt-include=/usr/include/libexslt --with-iconv-lib=/opt/vagrant/embedded/lib --with-iconv-include=/opt/vagrant/embedded/include
...
/opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
...
Gem files will remain installed in /opt/vagrant/embedded/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /opt/vagrant/embedded/lib/ruby/gems/2.0.0/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out

Last error gave me the answer. I needed the build tools (gcc, libc-dev, ...). I think the libiconv is integrated in libc. I installed build tools and the problem was gone.

sudo apt-get install build-essential

Now the plugins install process work like a charm :)

thanks @morrizon, works like a charm now!

apt-get install libxslt-dev libxml2-dev build-essential

It was my first time installing on fresh servers I guess, so I didn't realise some dependencies like these could be needed.

I'd be good to add this somewhere in the README

This is still definitely happening for us on OS X 10.8.5.

Ok, after about 2 days of banging our heads on the wall with it it magically worked this morning. I'm not sure what changed as we haven't done anything differently...

Hey @morrizon, do you know if this will fix the issue on a mac?

Not really a proper solution, but downgrading Vagrant to 1.6.1 did help on OS X.

I also had the same problem running vagrant 1.6.2 on OS X 10.9.2. A hint at a potential solution came when Homebrew complained about missing Command Line Tools. They can be installed using:

xcode-select --install

Afterwards, I was able to install the aws vagrant plugin without any issues. Apparently this is the OS X equivalent to the linux solution pointed out by @nodje.

Hi @thinkstylestudio, maybe it has a similar issue on OS X. You can try to install missing tools as @floretan says. If you want to know the problem you must test the installation of Nokogiri using gem:

/Applications/Vagrant/embedded/bin/gem install nokogiri -v '1.6.2.1'

Same problem here, but

xcode-select --install

Always timeout

Having this problem too, but I definitely have the XCode CLI. Vagrant 1.6.2, nokigiri 1.6.2.1 and OS X 10.9.2.

Hi @morrizon I've run the command as you requested here is the output:
From what i can gather it's libxml2 that is simply missing. I'm a little unsure how to install that on a mac. Is it identical as linux?

Last login: Wed May 21 13:13:11 on ttys002
You have mail.
M:~ t$ /Applications/Vagrant/embedded/bin/gem install nokogiri -v '1.6.2.1'
Building native extensions.  This could take a while...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
    - 0001-Fix-parser-local-buffers-size-problems.patch
    - 0002-Fix-entities-local-buffers-size-problems.patch
    - 0003-Fix-an-error-in-previous-commit.patch
    - 0004-Fix-potential-out-of-bound-access.patch
    - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
    - 0006-Do-not-fetch-external-parsed-entities.patch
    - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
    - 0008-Improve-handling-of-xmlStopParser.patch
    - 0009-Fix-a-couple-of-return-without-value.patch
    - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
    - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Building libxslt-1.1.28 for nokogiri with the following patches applied:
    - 0001-Adding-doc-update-related-to-1.1.28.patch
    - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
    - 0003-Initialize-pseudo-random-number-generator-with-curre.patch
    - 0004-EXSLT-function-str-replace-is-broken-as-is.patch
    - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch
    - 0007-Separate-function-for-predicate-matching-in-patterns.patch
    - 0008-Fix-direct-pattern-matching.patch
    - 0009-Fix-certain-patterns-with-predicates.patch
    - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch
    - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
    - 0014-Fix-for-bug-436589.patch
    - 0015-Fix-mkdir-for-mingw.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxslt.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install
************************************************************************
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Applications/Vagrant/embedded/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... yes
Building libxml2-2.8.0 for nokogiri with the following patches applied:
    - 0001-Fix-parser-local-buffers-size-problems.patch
    - 0002-Fix-entities-local-buffers-size-problems.patch
    - 0003-Fix-an-error-in-previous-commit.patch
    - 0004-Fix-potential-out-of-bound-access.patch
    - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
    - 0006-Do-not-fetch-external-parsed-entities.patch
    - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
    - 0008-Improve-handling-of-xmlStopParser.patch
    - 0009-Fix-a-couple-of-return-without-value.patch
    - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
    - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin12.5.0/ports/libxml2/2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0001-Fix-parser-local-buffers-size-problems.patch...
Running 'patch' for libxml2 2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0002-Fix-entities-local-buffers-size-problems.patch...
Running 'patch' for libxml2 2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0003-Fix-an-error-in-previous-commit.patch...
Running 'patch' for libxml2 2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0004-Fix-potential-out-of-bound-access.patch...
Running 'patch' for libxml2 2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0005-Detect-excessive-entities-expansion-upon-replacement.patch...
Running 'patch' for libxml2 2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0006-Do-not-fetch-external-parsed-entities.patch...
Running 'patch' for libxml2 2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch...
Running 'patch' for libxml2 2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0008-Improve-handling-of-xmlStopParser.patch...
Running 'patch' for libxml2 2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0009-Fix-a-couple-of-return-without-value.patch...
Running 'patch' for libxml2 2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0010-Keep-non-significant-blanks-node-in-HTML-parser.patch...
Running 'patch' for libxml2 2.8.0... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0011-Do-not-fetch-external-parameter-entities.patch...
Running 'patch' for libxml2 2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/x86_64-apple-darwin12.5.0/libxml2/2.8.0)...
Building libxslt-1.1.28 for nokogiri with the following patches applied:
    - 0001-Adding-doc-update-related-to-1.1.28.patch
    - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
    - 0003-Initialize-pseudo-random-number-generator-with-curre.patch
    - 0004-EXSLT-function-str-replace-is-broken-as-is.patch
    - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch
    - 0007-Separate-function-for-predicate-matching-in-patterns.patch
    - 0008-Fix-direct-pattern-matching.patch
    - 0009-Fix-certain-patterns-with-predicates.patch
    - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch
    - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
    - 0014-Fix-for-bug-436589.patch
    - 0015-Fix-mkdir-for-mingw.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxslt.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install
************************************************************************
Extracting libxslt-1.1.28.tar.gz into tmp/x86_64-apple-darwin12.5.0/ports/libxslt/1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0001-Adding-doc-update-related-to-1.1.28.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0003-Initialize-pseudo-random-number-generator-with-curre.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0004-EXSLT-function-str-replace-is-broken-as-is.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0006-Fix-str-padding-to-work-with-UTF-8-strings.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0007-Separate-function-for-predicate-matching-in-patterns.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0008-Fix-direct-pattern-matching.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0009-Fix-certain-patterns-with-predicates.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0014-Fix-for-bug-436589.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/patches/libxslt/0015-Fix-mkdir-for-mingw.patch...
Running 'patch' for libxslt 1.1.28... OK
Running 'configure' for libxslt 1.1.28... OK
Running 'compile' for libxslt 1.1.28... OK
Running 'install' for libxslt 1.1.28... OK
Activating libxslt 1.1.28 (from /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ports/x86_64-apple-darwin12.5.0/libxslt/1.1.28)...
checking for main() in -llzma... no
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Applications/Vagrant/embedded/bin/ruby
    --help
    --clean
    --use-system-libraries
    --enable-static
    --disable-static
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --enable-cross-build
    --disable-cross-build
    --with-xml2lib
    --without-xml2lib
    --with-libxml2lib
    --without-libxml2lib


Gem files will remain installed in /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/t/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out
M:~ t$

@thinkstylestudio the output tells you the problem:

libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.

If you visit the link http://nokogiri.org/tutorials/installing_nokogiri.html you can read possibles solutions but you need to use macports or homebrew.

Got the same problem.

Enviroment:
Mac OSX last version
RVM last update
Brew updated
Vagrant 1.6.2

I installed as recommended:

xcode-select --install

I was able to install libiconv:

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install

I linked it to brew, with:

 brew link libiconv

Checked brew with:

brew update
brew doctor

I installed the gem nokogiri with:

gem install nokogiri -v '1.6.2.1' -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1  

I can see the gem installed with gem list and the correct version.
image

When I try to install vagrant omnibus plugin with:

vagrant plugin install vagrant-omnibus

I get the error:
image

Tried:

export NOKOGIRI_USE_SYSTEM_LIBRARIES=true.
vagrant plugin update

With the same result.

Any idea how to advance?

Thanks in advance

UPDATE:

Solved.
There was a small comment in brew doctor about the path. Added the correct path order to .bashrc and worked.

Excuses for the comment.

image

Finally got mine working with the fix from @fredngo Adding the dependency declaration around line 20.

Running OS X 1.8.5 with Vagrant 1.6.2, plugins now install fine.

I'm just going to use Vagrant 1.5.4 until this get's sorted out...

I don't know why 1.6.x is considered stable with such a crippling issue.
I don't know why this issue is closed.

You guys really should read the error message and look into mkmf.log to see what's going on.

I'm installing vagrant because I don't want to work with Mac OS Command Line utilities

I agree with Dzamir.

Personally I consider this to be an open issue, because a web dev (especially one just learning vagrant after years of MAMP/XAMPP) should not need to go diving into command line error logs just to install a basic plugin. It's not a matter of laziness it's a matter of priorities, and credibility of the software.

Really none of the solutions should require using system libraries, brew installing anything. Command line tools are required for any plugins because some plugins require a compiler (C extensions) and Vagrant can't ship with a full C toolchain.

Ultimately this seems to be caused by Nokogiri upstream changing some of the way they compile. It should be fully self-contained to the installer though. i.e. Install OS X, Install Vagrant, Install XCode, and it should work.

If someone can give me a solid repro or solution, I'd look into it, but on my end on the few macs we have around here things just work.

@mitchellh I can reproduce this on a new MacBook Air running OS X (v 10.9.2). Looking at the output from gem install nokogiri and vagrant plugin install below, it appears that Nokogiri is emitting a non-zero exit code during the compilation step for libxml2, which Vagrant picks up during the plugin installation and interprets as a failure. Maybe it's just the warning message emitted by Nokogiri during the gem installation. I'll look into this further. More details follow.

$ vagrant plugin install vagrant-omnibus
Installing the 'vagrant-omnibus' plugin. This can take a few minutes...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
        - 0001-Fix-parser-local-buffers-size-problems.patch
        - 0002-Fix-entities-local-buffers-size-problems.patch
        - 0003-Fix-an-error-in-previous-commit.patch
        - 0004-Fix-potential-out-of-bound-access.patch
        - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
        - 0006-Do-not-fetch-external-parsed-entities.patch
        - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
        - 0008-Improve-handling-of-xmlStopParser.patch
        - 0009-Fix-a-couple-of-return-without-value.patch
        - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
        - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.
$ gem install nokogiri -v '1.6.2.1'
Building native extensions.  This could take a while...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
        - 0001-Fix-parser-local-buffers-size-problems.patch
        - 0002-Fix-entities-local-buffers-size-problems.patch
        - 0003-Fix-an-error-in-previous-commit.patch
        - 0004-Fix-potential-out-of-bound-access.patch
        - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
        - 0006-Do-not-fetch-external-parsed-entities.patch
        - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
        - 0008-Improve-handling-of-xmlStopParser.patch
        - 0009-Fix-a-couple-of-return-without-value.patch
        - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
        - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Building libxslt-1.1.28 for nokogiri with the following patches applied:
        - 0001-Adding-doc-update-related-to-1.1.28.patch
        - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
        - 0003-Initialize-pseudo-random-number-generator-with-curre.patch
        - 0004-EXSLT-function-str-replace-is-broken-as-is.patch
        - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch
        - 0007-Separate-function-for-predicate-matching-in-patterns.patch
        - 0008-Fix-direct-pattern-matching.patch
        - 0009-Fix-certain-patterns-with-predicates.patch
        - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch
        - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
        - 0014-Fix-for-bug-436589.patch
        - 0015-Fix-mkdir-for-mingw.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxslt.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install
************************************************************************
Successfully installed nokogiri-1.6.2.1
1 gem installed
Installing ri documentation for nokogiri-1.6.2.1...
Building YARD (yri) index for nokogiri-1.6.2.1...
Installing RDoc documentation for nokogiri-1.6.2.1...
$ vagrant plugin install vagrant-omnibus
Installing the 'vagrant-omnibus' plugin. This can take a few minutes...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
        - 0001-Fix-parser-local-buffers-size-problems.patch
        - 0002-Fix-entities-local-buffers-size-problems.patch
        - 0003-Fix-an-error-in-previous-commit.patch
        - 0004-Fix-potential-out-of-bound-access.patch
        - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
        - 0006-Do-not-fetch-external-parsed-entities.patch
        - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
        - 0008-Improve-handling-of-xmlStopParser.patch
        - 0009-Fix-a-couple-of-return-without-value.patch
        - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
        - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.

Yeah, the red flag for me with regards to the Nokogiri stuff is that it worked before Nokogiri released a new version. I don't have the hard evidence yet but my gut tells me if nothing changed, then suddenly broke, it was caused by the thing that changed. In this case, it was Nokogiri.

Our solution going forward for this dep might be to just lock it down since we can't trust it to not break things in spectacular ways, unfortunately.

Sounds like a good approach.

When examining the gems included with the Vagrant install, nokogiri-1.6.1 is included. Pinning vagrant to use this included gem is a good solution.

This solution has worked on my laptop, and other laptops in our team that were running the same issue with trying to compile nokogiri-1.6.2.1.

@geauxvirtual could you detail how to pin Vagrant to that version of nokogiri?

From #3769
To pin vagrant to a specific version of nokigiri:
Quick fix: add s.add_dependency(%q, ["< 1.6.2"]) to ~/Applications/Vagrant/embedded/gems/specifications/vagrant-1.6.2.gemspec

Thanks @colinsteinmann

The downside of strict pinning is that it will increase compatibility issues with vagrant-aws and other plugins which have transitive dependency on nokogiri.

That gem should really be bundled into Ruby core. It causes soo much trouble...

@tmatilai as an aside, people should maybe not use xml and start using json ;)

is there a current workaround to this which has been agreed on ? Downgrading vagrant seems like a not-so-good idea to me - i love the new features with releases and would like to keep using the latest

I hacked together a script to do a full installation with @colinsteinmann's fix. It's worked for me well on 10.9. Haven't had a chance to try on 10.8, but should handle it.

EDIT: Does work on 10.8

The most pertinent line in @JacobHayes script which can be ran from Terminal/iTerm is the following:

sudo perl -p -i -e "s/^end$/\n  s.add_dependency\(\%q\<nokogiri\>, \[\"< 1.6.2\"\]\)\nend/" "/Applications/Vagrant/embedded/gems/specifications/vagrant-1.6.2.gemspec"

Then all the user has to do is vagrant plugin install <name> as specified in the documentation.

Of course, this makes the assumption that the User has already installed Vagrant and Command Line Tools. However, I think that is more often the case than a full blown install script.

True, but the CLT and Vagrant installs are idempotent (unless it's an upgrade/downgrade) so it's no hassle other than time. The script was made to get my coworkers and I up to date with ease, so I tried to make few assumptions. ;)

Also, for those of you trying to install vagrant-omnibus and vagrant-berkshelf, you have to install them in the correct order as vagrant-omnibus locks vagrant-berkshelf at 1.3.7 (whose troubles escape me now), so vagrant-berkshelf has to be installed after omnibus with the explicit version of 2.0.1.

@JacobHayes As vagrant-berkshelf 2.0.1 has pre-release dependencies, you have to lock it's version to avoid it being downgraded:

vagrant plugin install vagrant-berkshelf --plugin-version '>= 2.0.1'

Dropping the >= means that the version restriction is only used when installing it, but it's not stored.

We're seeing this issue when doing vagrant install vagrant-omnibus, which has no dependencies.

It would appear from https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/bundler.rb that the embedded vagrant gems are not being added to the gem path when installing a plugin, causing the bundler to attempt to install all of these gems elsewhere when installing a plugin.

If i'm understanding correctly, nokogiri 1.6 already comes with vagrant - so installing a pure-ruby plugin should not require any compiler toolchain.

We've elected to just downgrade to Vagrant 1.5 until this gets fixed.

our problems resolved after there recent nokogiri 1.6.3 release, which contains this fix affecting mac users:
sparklemotion/nokogiri#1101

@Tyrael Looks like 1.6.3.1 breaks the process:

$ vagrant plugin update vagrant-vmware-fusion
Updating plugins: vagrant-vmware-fusion. This may take a few minutes...
Building nokogiri using packaged libraries.
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.3.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.3.1'` succeeds before bundling.

from https://github.com/sparklemotion/nokogiri/commits/master it seems that there are some issues detecting the support of the compiler flag:
sparklemotion/nokogiri@3c3d34f

I second @jonbuffington 's comment, looks like this problem is back again in Vagrant 1.6.3. I'm happy to attach logs or whatever diagnostic is needed, but first I need to know where to locate those. BTW, I was able to install nokogiri 1.6.3.1 without incident (using Ruby 2.1.2).

It reappeared in 1.6.3, Ruby 2.0.0.
Using the trick described earlier

$ export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
$ vagrant plugin install vagrant-vbguest

You can, again, work around this.

@pierot I am unable to update vagrant-vmware-fusion using the work around.

$ export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
$ vagrant plugin update vagrant-vmware-fusion
Updating plugins: vagrant-vmware-fusion. This may take a few minutes...
Building nokogiri using system libraries.
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:

An error occurred while installing nokogiri (1.6.3.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.3.1'` succeeds before bundling.

FWIW, I am on OS X 10.9.4 and using Xcode 5.1.1 without the command line tools installed.

$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]

I don't think that you can install the nokogiri gem without a c compiler, so you either need the command line tools installed or install gcc or clang from some other source.
NOKOGIRI_USE_SYSTEM_LIBRARIES only controls whether nokogiri should download the libxml/libxslt/libiconv source tarballs, patch them, and compile the libs to be available for linking to nokogiri, or to use the libs already installed on the system.
if you don't wanna compile nokogiri, you can use the 1.6.1 version shipped with vagrant through adding an explicit dependency to the vagrant gemspec file as mentioned in #3769 (comment)

@jonbuffington: What are the results of running gem install nokogiri -v '1.6.3.1'?

@Tyrael Right. Xcode symlinks the developer tools:

$ cc --version
Apple LLVM version 6.0 (clang-600.0.41.2) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

The command line tools are an optional subset package if you do not want to install the Xcode IDE.

Thanks for the reminder about editing the vagrant gemspec. I was hoping Hashicorp would have resolved this for the commercial plugin, vagrant-vmware-fusion.

@jonbuffington oh, so you are using the pre-release Yosemite? I think there is not much the vagrant devs can do about a problem in a gem which isn't really a immidiate dependency of vagrant a transient dep for some plugin.
apart from rewriting vagrant to go ofc. :P

@Tyrael 10.9 is not Yosemite, it's Mavericks, a public release of Mac OS X. That being said, the Mac is a mess of OS versions, compilers, libraries, Ruby versions, gem versions, etc. I know the pain firsthand. I wholeheartedly support rewriting this entire project in Go.

@pierot It seems that using the system libraries would require having precisely the patched version of libxml2 that nokogiri requires. I tried several flags to try to convince it to use the previously built libraries in /Applications/Vagrant/embedded, but it kept telling me I need version 2.6.21 or later (is that even accurate?).

@Tyrael Good catch. I was rushing to a meeting and pasted from the wrong system. I am using stock OS X 10.9.4 with Xcode 5.1.1:

$ cc --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix

@sgerrand I am getting the same issue as @nlfiedler

$ export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
$ gem install nokogiri -v '1.6.3.1'
Fetching: mini_portile-0.6.0.gem (100%)
Successfully installed mini_portile-0.6.0
Building native extensions.  This could take a while...
Building nokogiri using system libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    --help
    --clean
    --use-system-libraries=true
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-libxml-2.0-config
    --without-libxml-2.0-config
    --with-pkg-config
    --without-pkg-config
    --with-xslt-dir
    --without-xslt-dir
    --with-xslt-include
    --without-xslt-include=${xslt-dir}/include
    --with-xslt-lib
    --without-xslt-lib=${xslt-dir}/lib
    --with-libxslt-config
    --without-libxslt-config
    --with-exslt-dir
    --without-exslt-dir
    --with-exslt-include
    --without-exslt-include=${exslt-dir}/include
    --with-exslt-lib
    --without-exslt-lib=${exslt-dir}/lib
    --with-libexslt-config
    --without-libexslt-config

Maybe I'm missing something here, but I don't see why you're trying to use
the system level libraries during a installation of Nokogiri when you don't
have the required version of libxml2 etc installed. Nokogiri comes with the
source code for both libxslt and libxml2 - have you tried installing it
with that?

@sgerrand I have tried everything short of voodoo to work around this problem. No, it certainly doesn't make sense to use the system libraries when nokogiri comes with exactly the set it needs, but it is repeatedly suggested, so out of desperation I try it. I am reporting what I see. If you have other advice on this matter, I'm all ears.

Current status: system-wide, I have Ruby 2.1.2p95, gem 2.2.2, and nokogiri 1.6.3.1 installed, with little trouble (using Mac OS X 10.7.5, Xcode 4.6.3, gcc 4.2.1). As for Vagrant 1.6.3, a series of disappointing failures while attempting to install plugins.

BTW, could someone please reopen this issue? Or a new one? Either way, it is clearly a problem for multiple users.

@sgerrand I have tried everything short of voodoo to work around this
problem. No, it certainly doesn't make sense to use the system libraries
when nokogiri comes with exactly the set it needs, but it is repeatedly
suggested, so out of desperation I try it. I am reporting what I see. If
you have other advice on this matter, I'm all ears.

Current status: system-wide, I have Ruby 2.1.2p95, gem 2.2.2, and
nokogiri 1.6.3.1 installed, with little trouble (using Mac OS X 10.7.5,
Xcode 4.6.3, gcc 4.2.1). As for Vagrant 1.6.3, a series of disappointing
failures while attempting to install plugins.

Fair enough. I don't have access to a computer running OS X v10.7, but will
see what I can find at work tomorrow.

I've been toying around with removing the nokogiri dependency from the winrm gem, which Vagrant uses for Windows guests. This won't fix the underlying issue, but it reduces the likelihood of plugins using incompatible Nokogiri versions.

@nlfiedler x86_64-apple-darwin14.0.0 and clang-600.0.41.2 is definitely yosemite, @jonbuffington mentioned later that he posted the cc --version from the wrong system.
@jonbuffington just to make sure: so the nokogiri install fails from vagrant plugin install and it also fails when you try installing manually via gem install, with and without NOKOGIRI_USE_SYSTEM_LIBRARIES?
For the record I'm able to install the latest nokogiri gem (letting it to compile the libraries for itself), and as far as I can tell we are using the same version of everything, the only difference is that you don't have the command line tools installed while I do have it.
Could you show me the output of
gem install --verbose nokogiri -v '1.6.3.1'
without any NOKOGIRI_USE_SYSTEM_LIBRARIES?

why does this keep getting closed? i'm running into this issue even with vagrant 1.6.3. has there been an approved and proven work around? people are buying the provider package thinking things will work out of the box.

"why does this keep getting closed?"
it is most likely not a vagrant issue per see:
some vagrant plugins depend on nokogiri which can be problematic to install (it is a C extension, depending on multiple libraries with specific versions).
while vagrant itself doesn't depend on nokogiri, it by default ships a pre-built version of it,
unfortunately it doesn't help much, because different vagrant versions can come with different nokogiri versions, and the vagrant plugins have to support multiple versions, so adding an explicit nokogiri version dependency to the vagrant plugin is not a realistic approach.
which means that users using vagrant plugins having immediate or transitive dependency to nokogiri has to be able to install nokogiri to use those plugins.
as mentioned above, nokogiri can be a tricky beast to install, and it has a couple of build issues recently, mostly on the Mac OS platform.
We can help you figure out your build problems here, or if you want a quick workaround, then check out my previous comment(#3769 (comment)) about adding an explicit dependency to the vagrant.gemspec file which forces bundler to accept the pre-build nokogiri version as the most satisfying, so it won't try to install (and fail) the latest one.

Vagrant bundles nokogiri from the 1.6.x series. If a plugin declares gem.add_runtime_dependency 'nokogiri', '~> 1.6, will installing that plugin cause a new copy of nokogiri to be installed? If so, why is that, since the dependence is already satisfied by the bundled version?

Another question- if a plugin does not have any dependency on nokogiri, could installing that plugin cause nokogiri to be installed? If so, why? That appears to be happening in devopsgroup-io/vagrant-hostmanager#110

@Tyrael I followed your earlier suggestion and insert the following into Applications/Vagrant/embedded/gems/specifications/vagrant-1.6.3.gemspec at L22:

    #
    # JCB 2014-07-24
    s.add_dependency(%q<nokogiri>, ["= 1.6.2.1"])
    #

as Vagrant 1.6.3 ships with nokogiri 1.6.2.1:

$ mdfind libxml2
/usr/local/Library/Formula/libxml2.rb
/Applications/Vagrant/embedded/share/aclocal/libxslt.m4
/Applications/Vagrant/embedded/share/aclocal/libxml.m4
/Applications/Vagrant/embedded/lib/python2.7/site-packages/libxslt.py
/Applications/Vagrant/embedded/lib/pkgconfig/libxml-2.0.pc
/Applications/Vagrant/embedded/lib/xml2Conf.sh
/Applications/Vagrant/embedded/lib/libxml2.dylib
/Applications/Vagrant/embedded/lib/libxml2.a
/Applications/Vagrant/embedded/lib/libxml2.2.dylib
/Applications/Vagrant/embedded/include/libxslt/xsltInternals.h
/Applications/Vagrant/embedded/include/libxslt/xsltconfig.h
/Applications/Vagrant/embedded/include/libxml2
/Applications/Vagrant/embedded/include/libxml2/libxml/xpath.h
/Applications/Vagrant/embedded/include/libxml2/libxml/xmlversion.h
/Applications/Vagrant/embedded/include/libxml2/libxml/tree.h
/Applications/Vagrant/embedded/include/libxml2/libxml/DOCBparser.h
/Applications/Vagrant/embedded/include/libxml2/libxml/c14n.h
/Applications/Vagrant/embedded/gems/specifications/nokogiri-1.6.2.1.gemspec
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/test/xml/test_xpath.rb
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/test/files/atom.xml
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/tasks/test.rb
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/lib/nokogiri/html/element_description_defaults.rb
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/lib/nokogiri/html/document.rb
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/lib/nokogiri/version.rb
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/ext/nokogiri/xml_node.c
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/ext/nokogiri/xml_libxml2_hacks.o
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/ext/nokogiri/xml_libxml2_hacks.h
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/ext/nokogiri/xml_libxml2_hacks.c
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/ext/nokogiri/nokogiri.h
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/ext/nokogiri/nokogiri.c
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/ext/nokogiri/mkmf.log
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/ext/nokogiri/Makefile
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/ext/nokogiri/extconf.rb
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/README.rdoc
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/README.ja.rdoc
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/Rakefile
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/Manifest.txt
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/dependencies.yml
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/CHANGELOG.rdoc
/Applications/Vagrant/embedded/gems/gems/nokogiri-1.6.2.1/CHANGELOG.ja.rdoc
/Applications/Vagrant/embedded/gems/gems/bundler-1.6.2/spec/commands/config_spec.rb
/Users/jcb/Projects/basebox-packer/template/ubuntu/script/provisioner.sh
/usr/lib/libxml2.2.dylib

I was finally able to complete:

$ vagrant plugin update vagrant-vmware-fusion
Updating plugins: vagrant-vmware-fusion. This may take a few minutes...
All plugins are up to date.

I only wanted to install the Hashicorp licensed plugin.

@sciurus
gem.add_runtime_dependency 'nokogiri', '~> 1.6
is satisfied by the highest available 1.6.x version, having a lower micro version already installed doesn't change this as far as I'm concerned.
about why does nokogiri get pulled in when a plugin doesn't depend on it: vagrant plugin-install seems not just installing the given plugin, but re-evaluating the dependencies for every vagrant gem installed and installing anything which has a newer version available(and allowed by the gemspecs).

thanks @Tyrael

the solution worked. i get it, it's not a vagrant issue...but it could be perceived that way (new users mostly). in my case, i noticed it when installing the vmware plugin to draft a presentation on vmware/vagrant next week. when people start paying for things, sometimes all the logistics in the background get all muddied up (so do expectations). looks like everyone's all over it though! great job...vagrant is a great project!

My expectation of vagrant plugin install was that it would install the gems necessary to make the plugin work, not perform updates. I'd only expect it to perform updates if that was necessary to resolve dependencies.

To put in it bundler terms, I think of vagrant plugin install as adding a new gem to an existing Gemfile. If after doing that I ran bundle install, I think bundler would only install install the missing dependencies of the new gem, it wouldn't upgrade any dependencies it shared with existing gems. Of course, it might not be possible to satisfy the version constraints of the new gem with the currently installed versions of its dependencies. In that case I would have to run bundle update.

If vagrant plugin install is always doing the equivalent of bundle update, I can understand how that might simplify the code, but it's wasting time and electricity and raising the chance of failures like the one that prompted this bug report.

As suggested above. I did exactly this at line 22 and it fixes the issue.

22  s.add_dependency(%q<nokogiri>, ["= 1.6.2.1"])

Is this the final resolution to this? Or is there a cleaner solution.

Literally just did this on a fresh install of OS X.

Command Line Tools

I have found that it is crucial that Apple's standalone version of Command Line Tools is installed. You should find them at /Library/Developer/CommandLineTools.

For OSX <= 10.9, these can be installed by running xcode-select --install. However for OS X Yosemite v10.10-Beta4, you may likely need to find the latest DMG of the standalone instance. The file name I found was command_line_tools_for_os_x_yosemite_late_july_2014.dmg. However, it looks like the Apple Downloads and ADC Members section had its filesystem changed. So look for a mirror.

Homebrew

Next I installed Homebrew.
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Ran the following to update my libraries:

brew install libxml2 libxslt libiconv
brew link libxml2 libxslt

Nokogiri

You are finally ready to install nokogiri:

sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib

You could probably get away with doing the following if this is the first time you go through this process:

sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/*/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/*/lib --with-xslt-dir=/usr/local/Cellar/libxslt/* --with-iconv-include=/usr/local/Cellar/libiconv/*/include --with-iconv-lib=/usr/local/Cellar/libiconv/*/lib

References

Nokogiri | shade.sh

@jallits you only need to manually install libxml2/libxslt/libiconv if nokogiri for some reason can't install it's own dependencies and in which case you also have to use NOKOGIRI_USE_SYSTEM_LIBRARIES=true
if you managed to install the nokogiri gem to your system wide gem location that is nice, but AFAIK vagrant plugin install will still try to install nokogiri as it uses it's own gem installation and gem location (/Applications/Vagrant/embedded/gems/gems and ~/.vagrant.d/gems/gems) so even if you pass the lib locations to the manual gem installations, that won't do anything when your plugin install tries to install nokogiri to ~/.vagrant.d/gems/gems

I did a little bit more digging why does vagrant try to upgrade nokogiri when installing a plugin which seemingly doesn't have any dependency for it.
It seems that we are generating a bunch of gemfiles (10 gemfile and 3 lockfile for me) on a simple plugin install (it is already reported at #4103)
But based on my tests, it seems that the unnecessary plugin upgrade is caused by a lockfile, which shouldn't even be loaded according to the commit message in
5197d3d
At least non of the other gem/lockfiles generated by the plugin install command has any reference to the nokogiri 1.6.3.1 version, only to the pre-installed 1.6.2.1.

for testing/reproducing the issue, one should remove any other nokogiri gem from ~./.vagrant.d via

rm ~/.vagrant.d/gems/specifications/nokogiri-*.gemspec
rm -rf ~/.vagrant.d/gems/gems/nokogiri-*

then create a directory for the tmp files (so you don't have to look up your ruby tmpdir and tell apart the old vagrant gem/lockfiles from the ones created in this test)

mkdir vagrant_tmp

then execute a plugin install with a plugin which doesn't have nokogiri dependency, I choose vagrant-hostmanager:

vagrant plugin uninstall vagrant-hostmanager
TMPDIR=$PWD"/vagrant_tmp" vagrant plugin install --debug --verbose vagrant-hostmanager

this will trigger the nokogiri install (at least on my system), and leave behind a bunch of files in vagrant_tmp:

[tyrael@Ferencs-MacBook-Pro-135 ~ ]$ grep nokogiri -R vagrant_tmp/
vagrant_tmp//vagrant-gemfile20140731-13145-1nvjfol.lock:      nokogiri
vagrant_tmp//vagrant-gemfile20140731-13145-1nvjfol.lock:    nokogiri (1.6.3.1)
vagrant_tmp//vagrant-gemfile20140731-13145-1nvjfol.lock:      nokogiri (>= 1.4.0)
vagrant_tmp//vagrant-gemfile20140731-13145-1nvjfol.lock:      nokogiri (>= 1.4.0)
vagrant_tmp//vagrant-gemfile20140731-13145-1nvjfol.lock:      nokogiri (~> 1.5)
vagrant_tmp//vagrant20140731-13145-yh83sw2.lock:      nokogiri
vagrant_tmp//vagrant20140731-13145-yh83sw2.lock:    nokogiri (1.6.2.1)
vagrant_tmp//vagrant20140731-13145-yh83sw2.lock:      nokogiri (>= 1.4.0)
vagrant_tmp//vagrant20140731-13145-yh83sw2.lock:      nokogiri (>= 1.4.0)
vagrant_tmp//vagrant20140731-13145-yh83sw2.lock:      nokogiri (~> 1.5)

but only the vagrant-gemfile (which should be ignore according to @mitchellh's commit refers to the latest nokogiri version. /cc @sciurus

@Tyrael thanks for digging into this. Could you open a new issue based on your investigation?

OSX 10.10 public beta, Xcode 6 beta, Vagrant 1.6.3

I didn't install the Xcode command line tools at all, I simply ran:

xcode-select -s /Applications/Xcode6-Beta3.app/

I got the same error as reported by others here when trying to install a Vagrant plugin (the VMware Fusion plugin, actually). I ran the following to investigate further as suggested by the vagrant error output:

 sudo /Applications/Vagrant/embedded/bin/gem install nokogiri -v '1.6.3.1'

libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.

I installed Homebrew to /opt/homebrew, installed libiconv with brew install homebrew/dupes/libiconv, then confirmed that I could install nokogiri with Vagrant's embedded Ruby (which completed without errors):

sudo ./gem install nokogiri -v '1.6.3.1' -- --with-xml2-include=/opt/homebrew/opt/libxml2/include/libxml2 --with-xml2-lib=/opt/homebrew/opt/libxml2/lib --with-xslt-dir=/opt/homebrew/opt/libxslt --with-iconv-include=/opt/homebrew/opt/libiconv/include --with-iconv-lib=/opt/homebrew/opt/libiconv/lib

I was still prevented from installed the vagrant plugin at this stage. I feel like I'm so close. It seems like all I need to do is copy the new embedded build of nokogiri somewhere.

Just tried the following, which causes no errors but does not fix plugin installation:

bundle config build.nokogiri -- --with-xml2-include=/opt/homebrew/opt/libxml2/include/libxml2 --with-xml2-lib=/opt/homebrew/opt/libxml2/lib --with-xslt-dir=/opt/homebrew/opt/libxslt --with-iconv-include=/opt/homebrew/opt/libiconv/include --with-iconv-lib=/opt/homebrew/opt/libiconv/lib

I tried to repeat this with the embedded bundle, but I get the following error:

zsh: ./bundle: bad interpreter: /Users/administrator/bamboo-builds/BUILD-VG-CORE-OSX-209/tmp.y: no such file or directory