Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/sh
# in case it's already installled
vagrant plugin uninstall vagrant-libvirt
# vagrant's copy of curl prevents the proper installation of ruby-libvirt
sudo mv /opt/vagrant/embedded/lib/libcurl.so{,.backup}
sudo mv /opt/vagrant/embedded/lib/libcurl.so.4{,.backup}
sudo mv /opt/vagrant/embedded/lib/libcurl.so.4.4.0{,.backup}
sudo mv /opt/vagrant/embedded/lib/pkgconfig/libcurl.pc{,.backup}
CONFIGURE_ARGS="with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib" vagrant plugin install vagrant-libvirt
# https://github.com/pradels/vagrant-libvirt/issues/541
export PATH=/opt/vagrant/embedded/bin:$PATH
export GEM_HOME=~/.vagrant.d/gems/2.3.4
export GEM_PATH=$GEM_HOME:/opt/vagrant/embedded/gems
gem uninstall ruby-libvirt
gem install ruby-libvirt
# put vagrant's copy of curl back
sudo mv /opt/vagrant/embedded/lib/libcurl.so{.backup,}
sudo mv /opt/vagrant/embedded/lib/libcurl.so.4{.backup,}
sudo mv /opt/vagrant/embedded/lib/libcurl.so.4.4.0{.backup,}
sudo mv /opt/vagrant/embedded/lib/pkgconfig/libcurl.pc{.backup,}
@bitjockey42

This comment has been minimized.

Copy link

@bitjockey42 bitjockey42 commented Jan 16, 2017

Thanks for this. This is the only work-around that's worked for me.

@jcf

This comment has been minimized.

Copy link

@jcf jcf commented Feb 7, 2017

@j883376 massive thanks from me too! This got me up and running on Linux 4.9.6-1-ARCH.

@stefancocora

This comment has been minimized.

Copy link

@stefancocora stefancocora commented Jun 5, 2017

On the current Archlinux snapshot this guide fails with a marshalling error. [1]

Kernel: 4.11.3-1-ARCH x86_64 (64 bit)
Distro: Arch Linux

pacman -Q|grep vagrant
vagrant 1.9.5-1
vagrant-substrate-605.0566498 ( as pulled from an update with pacman -Syu )
vagrant-substrate 599.d7cedfe-2 (after downgrade)

The fix [2] is to downgrade the vagrant-substrate package before running the steps in this gist.

Downgrading vagrant-substrate

sudo pacman -U /var/cache/pacman/pkg/vagrant-substrate-599.d7cedfe-2-x86_64.pkg.tar.xz

[1]
Error encountered when installing the vagrant-libvirt plugin

 /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/source.rb:192:in `load': Marshal.load reentered at marshal_load (RuntimeError)
        from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/source.rb:192:in `load_specs'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/bundler.rb:335:in `block in validate_configured_sources!'
        from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/source_list.rb:97:in `each'
        from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/source_list.rb:97:in `each_source'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/bundler.rb:333:in `validate_configured_sources!'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/bundler.rb:268:in `internal_install'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/bundler.rb:106:in `install'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/manager.rb:62:in `block in install_plugin'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/manager.rb:72:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/plugin/manager.rb:72:in `install_plugin'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/plugin/action/install_gem.rb:29:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/plugin/command/base.rb:14:in `action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/plugin/command/install.rb:32:in `block in execute'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/plugin/command/install.rb:31:in `each'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/plugin/command/install.rb:31:in `execute'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/plugins/commands/plugin/command/root.rb:66:in `execute'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/cli.rb:42:in `execute'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/lib/vagrant/environment.rb:308:in `cli'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.5/bin/vagrant:138:in `<main>'
@zinovyev

This comment has been minimized.

Copy link

@zinovyev zinovyev commented Jun 29, 2017

@stefancocora Thank you!

For those of you who don't have vagrant-substrate in pacman cache:

curl -o vagrant-substrate-599.d7cedfe-2-x86_64.pkg.tar.xz https://archive.archlinux.org/packages/v/vagrant-substrate/vagrant-substrate-599.d7cedfe-2-x86_64.pkg.tar.xz && sudo pacman -U vagrant-substrate-599.d7cedfe-2-x86_64.pkg.tar.xz
@j883376

This comment has been minimized.

Copy link
Owner Author

@j883376 j883376 commented Jul 14, 2017

As of the package updates released a couple of days ago, the Ruby version has changed to 2.3.4. I've updated the Gist to point to the new directory to install ruby-libvirt to this directory. This fixes the following error after you've upgraded your packages.

/opt/vagrant/embedded/gems/gems/fog-libvirt-0.3.0/lib/fog/libvirt/requests/compute/list_domains.rb:76:in `domain_to_attributes': undefined method `active?' for #<Libvirt::Domain:0x00560c6c4108d8> (NoMethodError)

If you have added vagrant-substrate to your IgnorePkg list, remove it from the list and upgrade all Vagrant related packages, then rerun the latest version of this script.

@nebril

This comment has been minimized.

Copy link

@nebril nebril commented Sep 11, 2017

Thanks! I had to run this two times since I didn't have ruby-libvirt gem installed, but it worked in the end.

@zimmerle

This comment has been minimized.

Copy link

@zimmerle zimmerle commented Oct 20, 2017

Thanks ;)

@kshlm

This comment has been minimized.

Copy link

@kshlm kshlm commented Nov 9, 2017

As of the vagrant-2.0.1-1, this is no longer needed. I was able to just to a vagrant plugin install vagrant-libvirt and have it just work. 😄

@stefancocora

This comment has been minimized.

Copy link

@stefancocora stefancocora commented Nov 9, 2017

Can confirm what @kshlm is saying.
For vagrant >= 2.0.1-1 the vagrant package replaces the vagrant-substrate, so vagrant-substrate isn't used anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment