Skip to content

Instantly share code, notes, and snippets.

@j883376
Last active April 13, 2021 18:00
Show Gist options
  • Save j883376/d90933620c7ed14daa4e0963e005377f to your computer and use it in GitHub Desktop.
Save j883376/d90933620c7ed14daa4e0963e005377f to your computer and use it in GitHub Desktop.
#!/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,}
@j883376
Copy link
Author

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
Copy link

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
Copy link

Thanks ;)

@kshlm
Copy link

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
Copy link

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