Vagrant: Nokogiri error installing plugin

Created on 23 May 2017  ยท  14Comments  ยท  Source: hashicorp/vagrant

When I try and install vagrant-vsphere I get an error about a failure to build and install nokogiri. I'm not sure if this just means that this plugin is missing a changed nokogiri dependency (since vagrant just changed something here), of it it means I need to rebuild something to be compatible. Either way, I'm not sure how to proceed.

The error I get is:

$ vagrant plugin install vagrant-vsphere
Installing the 'vagrant-vsphere' plugin. This can take a few minutes...
Fetching: mini_portile2-2.1.0.gem (100%)
Building native extensions.  This could take a while...
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:

ERROR: Failed to build gem native extension.

    /opt/vagrant/embedded/bin/ruby -r ./siteconf20170522-79558-1qfwtxq.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv using --with-opt-* flags... no
checking for iconv... no
pkg-config could not be used to find libiconv
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1.7"

checking for iconv using pkg-config libiconv... no
-----
libiconv is missing.  Please locate mkmf.log to investigate how it is failing.
-----
*** 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=/opt/vagrant/embedded/bin/$(RUBY_BASE_NAME)
    --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

extconf failed, exit code 1

Note that this is a duplicate of a bug I opened over at https://github.com/nsidc/vagrant-vsphere/issues/240 - since googling a solution isn't getting me anywhere and I suspect that this is a somewhat general problem and not just a vsphere one.

core

Most helpful comment

That was fixed by https://github.com/mitchellh/vagrant-installers/pull/104

@chrisroberts Could you please release a new Vagrant version, with this installer fix.
Currently, Vagrant 1.9.5 is incompatible with several 3rd-party plugins depending on nokogiri. Thanks.

All 14 comments

If I set export NOKOGIRI_USE_SYSTEM_LIBRARIES=true then I get this instead:

$ vagrant plugin install vagrant-vsphere
Installing the 'vagrant-vsphere' plugin. This can take a few minutes...
Building native extensions.  This could take a while...
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:

ERROR: Failed to build gem native extension.

    /opt/vagrant/embedded/bin/ruby -r ./siteconf20170523-25080-oy361q.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using system libraries.
pkg-config could not be used to find libxml-2.0
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1.7"

pkg-config could not be used to find libxslt
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1.7"

pkg-config could not be used to find libexslt
Please install either `pkg-config` or the pkg-config gem per

    gem install pkg-config -v "~> 1.1.7"

ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
*** 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=/opt/vagrant/embedded/bin/$(RUBY_BASE_NAME)
    --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

extconf failed, exit code 1

That was fixed by https://github.com/mitchellh/vagrant-installers/pull/104

@chrisroberts Could you please release a new Vagrant version, with this installer fix.
Currently, Vagrant 1.9.5 is incompatible with several 3rd-party plugins depending on nokogiri. Thanks.

I'm experiencing this issue when running:
vagrant plugin install vagrant-aws

bug is also reproducable on Mac OS 10.12.5

ERROR: Failed to build gem native extension.

/opt/vagrant/embedded/bin/ruby -r ./siteconf20170526-6465-re45n.rb extconf.rb

checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv using --with-opt-* flags... no
checking for iconv... no
pkg-config could not be used to find libiconv
Please install either pkg-config or the pkg-config gem per

gem install pkg-config -v "~> 1.1.7"

checking for iconv using pkg-config libiconv... no

libiconv is missing. Please locate mkmf.log to investigate how it is failing.

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

I also encountered the same issue when installing vagrant-vsphere plugin.
My vagrant is 1.9.5 and Mac OS is 10.12.

Same problem 10.12.5
with vagrant plugin install vagrant-libvirt

$ vagrant version
Installed Version: 1.9.5
Latest Version: 1.9.5

You're running an up-to-date version of Vagrant!

I bypassed the issue by downgrading vagrant to 1.9.4. The problem is solved.

Same as @shawnho1018 , Downgrading to vagrant 1.9.4 fixed it.

@ggascoigne can you test with latest version?

Not only did it just work, but this might be the first time ever where vagrant plugin repair didn't explode on me, instead it worked, fetched nokogiri-1.8.0.gem, built the native extensions and moved on correctly.

The vagrant-vsphere plugin (v 1.12.1) loaded and worked correctly.

As far as I can tell this bug looks fixed. Thank you.

for good measure I also uninstalled the vagrant-vsphere plugin and reinstalled it, all with no issues.

@ggascoigne which version worked for you? Using 1.9.7 and getting the same error.

I'm using:

 $ vagrant --version
Vagrant 1.9.7
 $ vagrant plugin list
vagrant-berkshelf (5.1.1)
  - Version Constraint: > 0
vagrant-docker-compose (1.3.0)
  - Version Constraint: > 0
vagrant-omnibus (1.5.0)
  - Version Constraint: > 0
vagrant-scp (0.5.7)
  - Version Constraint: > 0
vagrant-share (1.1.9, system)
  - Version Constraint: > 0
vagrant-vsphere (1.12.1)

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

janw-me picture janw-me  ยท  3Comments

hesco picture hesco  ยท  3Comments

DreadPirateShawn picture DreadPirateShawn  ยท  3Comments

bbaassssiiee picture bbaassssiiee  ยท  3Comments

luispabon picture luispabon  ยท  3Comments