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

Installation on macOS #818

Closed
mignz opened this issue Oct 7, 2017 · 7 comments
Closed

Installation on macOS #818

mignz opened this issue Oct 7, 2017 · 7 comments

Comments

@mignz
Copy link

mignz commented Oct 7, 2017

Is this even possible? I want to run a QEMU vm through libvirt using the latest macOS High Sierra.

Some folks managed to get it to work here #497, but mine just won't. Here's what I did so far:

$ brew install qemu libvirt gcc ruby ruby-build rbenv libiconv
$ brew upgrade libxml2
$ export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
$ vagrant plugin install vagrant-libvirt

This doesn't work. Libxml2 version installed through Homebrew is 2.9.6. My vagrant version is 2.0.0. Libvirt is 3.8.0.

Then I've tried the rbenv workaround by installing the ruby version Vagrant uses to rbenv ($ rbenv install 2.3.4 && rbenv shell 2.3.4).

The error message is always the same:

$ vagrant plugin install vagrant-libvirt
Installing the 'vagrant-libvirt' 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.

    current directory: /Users/mike/.vagrant.d/gems/2.3.4/gems/nokogiri-1.6.6.4/ext/nokogiri
/opt/vagrant/embedded/bin/ruby -r ./siteconf20171007-47210-128uwlw.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.
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
	--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

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/mike/.vagrant.d/gems/2.3.4/extensions/x86_64-darwin-13/2.3.0/nokogiri-1.6.6.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/mike/.vagrant.d/gems/2.3.4/gems/nokogiri-1.6.6.4 for inspection.
Results logged to /Users/mike/.vagrant.d/gems/2.3.4/extensions/x86_64-darwin-13/2.3.0/nokogiri-1.6.6.4/gem_make.out

And here's the mkmf.log file:

$ cat /Users/mike/.vagrant.d/gems/2.3.4/extensions/x86_64-darwin-13/2.3.0/nokogiri-1.6.6.4/mkmf.log
"clang -o conftest -I/opt/vagrant/embedded/include/ruby-2.3.0/x86_64-darwin13 -I/opt/vagrant/embedded/include/ruby-2.3.0/ruby/backward -I/opt/vagrant/embedded/include/ruby-2.3.0 -I.  -I/opt/vagrant/embedded/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I/opt/vagrant/embedded/include -I/vagrant-substrate/cache/ruby-2.3.4/include -fno-common -pipe  conftest.c  -L. -L/opt/vagrant/embedded/lib -L/opt/vagrant/embedded/lib -L. -L/opt/vagrant/embedded/lib  -Wl,-rpath,@loader_path/../lib -Wl,-rpath,@executable_path/../lib -Wl,-rpath,/opt/vagrant/embedded/lib -fstack-protector -L/usr/local/lib -L/opt/vagrant/embedded/lib   -arch x86_64   -lruby.2.3.0  -lpthread -ldl -lobjc  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"clang -I/opt/vagrant/embedded/include/ruby-2.3.0/x86_64-darwin13 -I/opt/vagrant/embedded/include/ruby-2.3.0/ruby/backward -I/opt/vagrant/embedded/include/ruby-2.3.0 -I.  -I/opt/vagrant/embedded/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I/opt/vagrant/embedded/include -I/vagrant-substrate/cache/ruby-2.3.4/include -fno-common -pipe   -arch x86_64  -Werror -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

"clang -I/opt/vagrant/embedded/include/ruby-2.3.0/x86_64-darwin13 -I/opt/vagrant/embedded/include/ruby-2.3.0/ruby/backward -I/opt/vagrant/embedded/include/ruby-2.3.0 -I.  -I/opt/vagrant/embedded/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I/opt/vagrant/embedded/include -I/vagrant-substrate/cache/ruby-2.3.4/include -fno-common -pipe  -Wno-error=unused-command-line-argument-hard-error-in-future  -arch x86_64  -Werror -c conftest.c"
error: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Werror,-Wunknown-warning-option]
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

"pkg-config --exists libxml-2.0"
dyld: Symbol not found: _iconv
  Referenced from: /usr/lib/libcups.2.dylib
  Expected in: /opt/vagrant/embedded/lib/libiconv.2.dylib
 in /usr/lib/libcups.2.dylib
package configuration for libxml-2.0 is not found
"pkg-config --exists libxslt"
dyld: Symbol not found: _iconv
  Referenced from: /usr/lib/libcups.2.dylib
  Expected in: /opt/vagrant/embedded/lib/libiconv.2.dylib
 in /usr/lib/libcups.2.dylib
package configuration for libxslt is not found
"pkg-config --exists libexslt"
dyld: Symbol not found: _iconv
  Referenced from: /usr/lib/libcups.2.dylib
  Expected in: /opt/vagrant/embedded/lib/libiconv.2.dylib
 in /usr/lib/libcups.2.dylib
package configuration for libexslt is not found
"clang -E -I/opt/vagrant/embedded/include/ruby-2.3.0/x86_64-darwin13 -I/opt/vagrant/embedded/include/ruby-2.3.0/ruby/backward -I/opt/vagrant/embedded/include/ruby-2.3.0 -I.  -I/opt/vagrant/embedded/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I/opt/vagrant/embedded/include -I/vagrant-substrate/cache/ruby-2.3.4/include -fno-common -pipe   conftest.c -o conftest.i"
conftest.c:3:10: fatal error: 'libxml/xmlversion.h' file not found
#include <libxml/xmlversion.h>
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <libxml/xmlversion.h>
4: 
5: #if LIBXML_VERSION < 20621
6: #error libxml2 is way too old
7: #endif
/* end */

I do not know how to make it use the latest libxml2, if that's the issue.

Anyone tried this?

@ccosby
Copy link

ccosby commented Oct 9, 2017

Did you actually try the steps in my comment (the one this issue is tied to)? It doesn't look like you did. Give that a shot first.

@mignz
Copy link
Author

mignz commented Oct 9, 2017

Fresh macOS install, no problems following your instructions. Now I don't know how to use QEMU but that's another problem.

@mignz mignz closed this as completed Oct 9, 2017
@mcandre
Copy link

mcandre commented Nov 14, 2017

Er, libvirt setup in macOS is still borked. This is the error I get on my machine:

$ vagrant up --provider libvirt
==> default: VM not created. Moving on...
Bringing machine 'default' up with 'libvirt' provider...
/opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': incompatible library version - /Users/andrew/.vagrant.d/gems/2.4.2/gems/ruby-libvirt-0.7.0/lib/_libvirt.bundle (LoadError)
	from /opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/andrew/.vagrant.d/gems/2.4.2/gems/ruby-libvirt-0.7.0/lib/libvirt.rb:11:in `<top (required)>'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/andrew/.vagrant.d/gems/2.4.2/gems/fog-libvirt-0.4.2/lib/fog/libvirt.rb:4:in `<top (required)>'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/andrew/.vagrant.d/gems/2.4.2/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/driver.rb:1:in `<top (required)>'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/andrew/.vagrant.d/gems/2.4.2/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/provider.rb:29:in `driver'
	from /Users/andrew/.vagrant.d/gems/2.4.2/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/create_networks.rb:26:in `initialize'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:90:in `new'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:90:in `finalize_action'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:20:in `block in initialize'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:20:in `map'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:20:in `initialize'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builder.rb:170:in `new'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builder.rb:170:in `to_app'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builtin/call.rb:52:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builder.rb:116:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:66:in `block in run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/util/busy.rb:19:in `busy'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:66:in `run'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:227:in `action_raw'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:202:in `block in action'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb:631:in `lock'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:188:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine.rb:188:in `action'
	from /opt/vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'

This is AFTER running several convoluted steps just to get ruby-libvirt kinda-sorta installed with native extensions in the ~/.vagrant.d/gems/ directory. Now, I have no idea what is causing the incompatibility error, or how to go about resolving it in macOS. Some Arch users are having luck by forcibly installing the 0.6.0 version of ruby-libvirt. However, when I run vagrant plugin install vagrant-libvirt, that wipes my ruby-libvirt 0.6.0 and places ruby-libvirt 0.7.0 there anyway. So macOS users are hosed again when trying to run libvirt boxes :/

I eventually found an old version of the vagrant-libvirt plugin that targets (through fog-libvirt) ruby-libvirt 0.6.0: vagrant-libvirt 0.0.32. Unfortunately, after installing this via vagrant plugin install --plugin-version 0.0.32 vagrant-libvirt, the same annoying incompatible library version error occurs on vagrant up --provider libvirt.

I'm using Vagrant 2.0.1, libvirt 3.9.0, qemu 2.5.0_2, Homebrew 1.3.7, macOS High Sierra.

@ghost
Copy link

ghost commented Sep 10, 2019

Did you actually try the steps in my comment (the one this issue is tied to)? It doesn't look like you did. Give that a shot first.

#497 (comment)

@errordeveloper
Copy link

See also: #497 (comment)

@Falkor
Copy link

Falkor commented Apr 16, 2020

I have a somehow similar issue on Vagrant 2.2.7 (on Mac OS Mojave 10.14.6) using several options (from the basic vagrant plugin install vagrant-libvirt to more advanced tests as per #497 comments.
All fail to install nokogiri...

env CONFIGURE_ARGS="with-libvirt-lib=$(brew --prefix libvirt)/lib with-libvirt-include=$(brew --prefix libvirt)/include" vagrant plugin install vagrant-libvirt
Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
Building native extensions.  This could take a while...
Vagrant failed to properly resolve required dependencies. These
errors can commonly be caused by misconfigured plugin installations
or transient network issues. The reported error is:

ERROR: Failed to build gem native extension.

    current directory: /Users/svarrette/.vagrant.d/gems/2.4.9/gems/nokogiri-1.10.9/ext/nokogiri
/opt/vagrant/embedded/bin/ruby -r ./siteconf20200416-41711-97m7ak.rb extconf.rb
checking if the C compiler accepts -I/opt/vagrant/embedded/include -I/opt/vagrant/embedded/include/libxml2 -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2... *** 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
/opt/vagrant/embedded/lib/ruby/2.4.0/mkmf.rb:457:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from /opt/vagrant/embedded/lib/ruby/2.4.0/mkmf.rb:572:in `block in try_compile'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/mkmf.rb:523:in `with_werror'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/mkmf.rb:572:in `try_compile'
	from extconf.rb:138:in `nokogiri_try_compile'
	from extconf.rb:162:in `block in add_cflags'
	from /opt/vagrant/embedded/lib/ruby/2.4.0/mkmf.rb:630:in `with_cflags'
	from extconf.rb:161:in `add_cflags'
	from extconf.rb:416:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/svarrette/.vagrant.d/gems/2.4.9/extensions/x86_64-darwin-19/2.4.0/nokogiri-1.10.9/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/svarrette/.vagrant.d/gems/2.4.9/gems/nokogiri-1.10.9 for inspection.
Results logged to /Users/svarrette/.vagrant.d/gems/2.4.9/extensions/x86_64-darwin-19/2.4.0/nokogiri-1.10.9/gem_make.out

Here is the log:

"clang -o conftest -I/opt/vagrant/embedded/include/ruby-2.4.0/x86_64-darwin19 -I/opt/vagrant/embedded/include/ruby-2.4.0/ruby/backward -I/opt/vagrant/embedded/include/ruby-2.4.0 -I. -I/opt/vagrant/embedded/include -I/opt/vagrant/embedded/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I/opt/vagrant/embedded/include -fno-common -pipe -I/opt/vagrant/embedded/include -I/opt/vagrant/embedded/include/libxml2 -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2 conftest.c  -L. -L/opt/vagrant/embedded/lib -L/opt/vagrant/embedded/lib -L. -L/opt/vagrant/embedded/lib -fstack-protector -L/usr/local/lib -L/opt/vagrant/embedded/lib     -lruby.2.4.9  -lpthread -ldl -lobjc  "
dyld: Symbol not found: _iconv
  Referenced from: /usr/lib/libcups.2.dylib
  Expected in: /opt/vagrant/embedded/lib/libiconv.2.dylib
 in /usr/lib/libcups.2.dylib
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

Note that I have reinstalled the missing header files

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
cd /Library/Developer/CommandLineTools/Packages/
open macOS_SDK_headers_for_macOS_10.14.pkg

I start to be out of options. The many bug reports (for instance nokogiri#1923 do not seem useful...

Any hint would be welcome...

Of course, a local install of nokogiri works like a charm...

rvm install 2.4.9
rvm gemset create test
rvm use 2.4.9@test 
gem install nokogiri

@Falkor
Copy link

Falkor commented Apr 18, 2020

Ok, so temporarily disabling /opt/vagrant/embedded/lib/libiconv.2.dylib solved the issue.

cd /opt/vagrant/embedded/lib/
sudo mv libiconv.2.dylib libiconv.2.dylib.orig
NOKOGIRI_USE_SYSTEM_LIBRARIES=1 CONFIGURE_ARGS="with-libvirt-include=$(brew --prefix libvirt)/include with-libvirt-lib=$(brew --prefix libvirt)/lib" vagrant plugin install vagrant-libvirt
Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
Building native extensions.  This could take a while...
Fetching: fog-json-1.2.0.gem (100%)
Fetching: fog-xml-0.1.3.gem (100%)
Fetching: ruby-libvirt-0.7.1.gem (100%)
Building native extensions.  This could take a while...
Fetching: fog-libvirt-0.7.0.gem (100%)
Fetching: vagrant-libvirt-0.0.45.gem (100%)
Installed the plugin 'vagrant-libvirt (0.0.45)'!
sudo mv libiconv.2.dylib.orig libiconv.2.dylib

`

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

5 participants