You are not logged in.

#1 2013-07-03 12:34:57

twouters
Member
Registered: 2010-04-01
Posts: 22

vagrant + vagrant-libvirt plugin

Hi,

I'm having some issues with installing the vagrant-libvirt plugin.
I've installed vagrant from AUR with yaourt and try to install the plugin with

$ vagrant plugin install vagrant-libvirt

The following error shows up:

Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
/opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:562:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /opt/vagrant/embedded/bin/ruby extconf.rb
checking for virNetworkPtr in libvirt/libvirt.h... *** 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
	--with-libvirt-include
	--without-libvirt-include
	--with-libvirt-lib
	--without-libvirt-lib
	--with-libvirt-config
	--without-libvirt-config
	--with-pkg-config
	--without-pkg-config
/opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:381: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/1.9.1/mkmf.rb:491:in `block in try_compile'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:443:in `with_werror'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:491:in `try_compile'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:1022:in `try_type'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:1050:in `block in have_type'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:254:in `open'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:254:in `open'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:1049:in `have_type'
	from extconf.rb:10:in `block in have_libvirt_types'
	from extconf.rb:10:in `each'
	from extconf.rb:10:in `have_libvirt_types'
	from extconf.rb:211:in `<main>'


Gem files will remain installed in /home/twouters/.vagrant.d/gems/gems/ruby-libvirt-0.4.0 for inspection.
Results logged to /home/twouters/.vagrant.d/gems/gems/ruby-libvirt-0.4.0/ext/libvirt/gem_make.out
	from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:540:in `block in build_extensions'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:515:in `each'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:515:in `build_extensions'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:180:in `install'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:297:in `block in install'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each_with_index'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `install'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/plugin/action/install_gem.rb:38:in `block in call'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/plugin/gem_helper.rb:42:in `block in with_environment'
	from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/user_interaction.rb:40:in `use_ui'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/plugin/gem_helper.rb:41:in `with_environment'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/plugin/action/install_gem.rb:28:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/plugin/action/bundler_check.rb:20:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/action/warden.rb:34:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/action/builder.rb:116:in `call'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/action/runner.rb:61:in `block in run'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/util/busy.rb:19:in `busy'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/action/runner.rb:61:in `run'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/plugin/command/base.rb:17:in `action'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/plugin/command/install.rb:44:in `execute'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/plugin/command/root.rb:47:in `execute'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/cli.rb:46:in `execute'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:467:in `cli'
	from /opt/vagrant/embedded/gems/gems/vagrant-1.2.2/bin/vagrant:84:in `<top (required)>'
	from /opt/vagrant/bin/../embedded/gems/bin/vagrant:23:in `load'
	from /opt/vagrant/bin/../embedded/gems/bin/vagrant:23:in `<main>'

I've had a look at the log file ~/.vagrant.d/gems/gems/ruby-libvirt-0.4.0/ext/libvirt/mkmf.log which contained a great pointer to the issue:

package configuration for libvirt
cflags: 
ldflags: 
libs: -lvirt -ldl 

"gcc -o conftest -I/opt/vagrant/embedded/include/ruby-1.9.1/x86_64-linux -I/opt/vagrant/embedded/include/ruby-1.9.1/ruby/backward -I/opt/vagrant/embedded/include/ruby-1.9.1 -I.    -I/tmp/vagrant-temp/embedded/include -I/tmp/vagrant-temp/embedded/include -L/tmp/vagrant-temp/embedded/lib -fPIC  conftest.c  -L. -L/opt/vagrant/embedded/lib -Wl,-R/opt/vagrant/embedded/lib -L/tmp/vagrant-temp/embedded/lib -Wl,-R/tmp/vagrant-temp/embedded/lib -L. -I/tmp/vagrant-temp/embedded/include -L/tmp/vagrant-temp/embedded/lib  -rdynamic -Wl,-export-dynamic       -lvirt -ldl  '-Wl,-rpath,/../lib' -Wl,-R -Wl,/opt/vagrant/embedded/lib -L/opt/vagrant/embedded/lib -lruby  -lpthread -lrt -ldl -lcrypt -lm   -lc"
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_global_init@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_multi_cleanup@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_easy_init@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_easy_setopt@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_multi_remove_handle@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_slist_free_all@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_share_init@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_multi_init@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_easy_cleanup@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_easy_perform@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_share_cleanup@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_easy_strerror@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_easy_getinfo@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_slist_append@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_share_setopt@CURL_OPENSSL_4'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../lib/libvirt.so: undefined reference to `curl_multi_add_handle@CURL_OPENSSL_4'
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

Libvirt has been installed on my system and is built against the system curl libraries, but vagrant is trying to use the embedded curl libraries in /opt/vagrant/embedded/lib/
I have "confirmed" this behaviour by removing the curl libs from /opt/vagrant/embedded/lib/ and /opt/vagrant/embedded/lib/pkgconfig/.
After removing the libs and pkgconfig file the installation of vagrant-libvirt succeeds.

$ vagrant plugin install vagrant-libvirt
Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
Installed the plugin 'vagrant-libvirt (0.0.5)'!

I know this isn't the right way to do this, so I wanted to ask if anyone knows how this should be fixed / worked around in a correct fashion.

Offline

#2 2014-03-01 13:23:38

Mic92
Member
From: Germany
Registered: 2009-07-05
Posts: 18
Website

Re: vagrant + vagrant-libvirt plugin

I had the same problem with vagrant-kvm.
And deleting libcurl was a temporary workaround for me too.

Here are the files which have to be removed (for copy'n'paste):

$ mv /opt/vagrant/embedded/lib/libcurl.so{,.backup}
$ mv /opt/vagrant/embedded/lib/libcurl.so.4{,.backup}
$ mv /opt/vagrant/embedded/lib/libcurl.so.4.3.0{,.backup}
$ mv /opt/vagrant/embedded/lib/pkgconfig/libcurl.pc{,backup}

This problem could be solved by creating custom ruby-libvirt gem for vagrant, which links against the system libcurl (by using LIBRARY_PATH).

Offline

#3 2016-03-12 15:51:05

blacky
Member
Registered: 2012-10-26
Posts: 12

Re: vagrant + vagrant-libvirt plugin

Thanks guys, solved the problem for me as well. Two years later, how sad … *Apologizing for unearthing this thread*

Offline

Board footer

Powered by FluxBB