vagrant-libvirt: Cannot install on OS X because of ruby-libvirt
Installing ruby-libvirt on OS X does not work because of
https://bugzilla.redhat.com/show_bug.cgi?id=1161338
domain.c:5439:29: error: use of undeclared identifier 'VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK'
INT2NUM(VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK));
^
/opt/vagrant/embedded/include/ruby-2.0.0/ruby/ruby.h:1167:35: note: expanded from macro 'INT2NUM'
# define INT2NUM(v) INT2FIX((int)(v))
^
/opt/vagrant/embedded/include/ruby-2.0.0/ruby/ruby.h:241:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
^
domain.c:5443:29: error: use of undeclared identifier 'VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT'
INT2NUM(VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT));
^
/opt/vagrant/embedded/include/ruby-2.0.0/ruby/ruby.h:1167:35: note: expanded from macro 'INT2NUM'
# define INT2NUM(v) INT2FIX((int)(v))
^
/opt/vagrant/embedded/include/ruby-2.0.0/ruby/ruby.h:241:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
^
domain.c:5447:29: error: use of undeclared identifier 'VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT'
INT2NUM(VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT));
^
/opt/vagrant/embedded/include/ruby-2.0.0/ruby/ruby.h:1167:35: note: expanded from macro 'INT2NUM'
# define INT2NUM(v) INT2FIX((int)(v))
^
/opt/vagrant/embedded/include/ruby-2.0.0/ruby/ruby.h:241:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
^
domain.c:5451:29: error: use of undeclared identifier 'VIR_DOMAIN_QEMU_MONITOR_COMMAND_DEFAULT'
INT2NUM(VIR_DOMAIN_QEMU_MONITOR_COMMAND_DEFAULT));
^
/opt/vagrant/embedded/include/ruby-2.0.0/ruby/ruby.h:1167:35: note: expanded from macro 'INT2NUM'
# define INT2NUM(v) INT2FIX((int)(v))
^
/opt/vagrant/embedded/include/ruby-2.0.0/ruby/ruby.h:241:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
^
domain.c:5455:29: error: use of undeclared identifier 'VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP'
INT2NUM(VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP));
^
/opt/vagrant/embedded/include/ruby-2.0.0/ruby/ruby.h:1167:35: note: expanded from macro 'INT2NUM'
# define INT2NUM(v) INT2FIX((int)(v))
^
/opt/vagrant/embedded/include/ruby-2.0.0/ruby/ruby.h:241:45: note: expanded from macro 'INT2FIX'
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 1
- Comments: 44 (3 by maintainers)
This actually works. vagrant on macOS, libvirt on Ubuntu 17.04
macOS Sierra 10.12.6 Vagrant 2.0.0
Install Homebrew
Install necessary Homebrew recipes.
Find the version of ruby used by your version of vagrant. Mine was 2.3.4
Install the vagrant plugin.
Remote Host: Ubuntu 17.04 (zesty) @ 192.168.15.127 libvirt-daemon 2.5.0-3ubuntu5.5
This Vagrantfile will start a debian/jessie64 box on the host at 192.168.15.127. TCP:4242 on your local machine will be forwarded to the box.
Example Vagrantfile:
Travis and Azure DevOps both provide free builders for MacOS, quite useful for testing and assuring that the plugin is at least builable and instalable.
I can confirm that adding the mentioned environment variables allows me to install the plugin, which means that the build code needs to be updated to avoid the need for them.
PS. If any maintainer needs access to a macos shell, please ping me on private and I will create an account for you on my box.
Few things said in this thread are a little confusing
CONFIGURE_ARGShave flags with double-dash or without?with-libvirt-lib=is same as--with-libvirt-lib=)with-ldflags=-L/opt/vagrant/embedded/libactually needed?NOKOGIRI_USE_SYSTEM_LIBRARIES=truelibiconvis actually needed or notHowever, key details that are more critical are these:
with-libvirt-include=${prefix}/include/libvirt#include <libvirt/libvirt.h>, so this will have to bewith-libvirt-include=${prefix}/include(note: it’s not the subdirectory)Here is what worked for me:
==> Downloading https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.dmg Already downloaded: /Users/ilya/Library/Caches/Homebrew/downloads/accec21e850b3dbacc4d406adebaecc0265de9b285c3e8431fcb7443f311d4d2–vagrant_2.2.7_x86_64.dmg ==> Verifying SHA-256 checksum for Cask ‘vagrant’. ==> Installing Cask vagrant ==> Running installer for vagrant; your password may be necessary. ==> Package installers may write to any location; options such as --appdir are ignored. installer: Package name is Vagrant installer: Installing at base path / installer: The install was successful. 🍺 vagrant was successfully installed! ==> Downloading https://libvirt.org/sources/libvirt-6.1.0.tar.xz Already downloaded: /Users/ilya/Library/Caches/Homebrew/downloads/42ed86b94110afc9b83a2cea9a114b765a8428faddac809ba6a1d260d8a09e1c–libvirt-6.1.0.tar.xz ==> …/configure --prefix=/Users/ilya/Library/Local/Homebrew/Cellar/libvirt/6.1.0 --localstatedir=/Users/ilya/Library/Local/Homebrew/var --mandir=/Users/ilya/Library/Local/Homebrew/Cel ==> make ==> make install ==> Caveats To have launchd start libvirt now and restart at login: brew services start libvirt Or, if you don’t want/need a background service you can just run: libvirtd ==> Summary 🍺 /Users/ilya/Library/Local/Homebrew/Cellar/libvirt/6.1.0: 532 files, 36.5MB, built in 2 minutes 7 seconds $ libvirt_prefix=“$(brew --prefix libvirt)” $ env CONFIGURE_ARGS=“with-libvirt-lib=${libvirt_prefix}/lib with-libvirt-include=${libvirt_prefix}/include” vagrant plugin install vagrant-libvirt
Installing the ‘vagrant-libvirt’ plugin. This can take a few minutes… Fetching: formatador-0.2.5.gem (100%) Fetching: excon-0.72.0.gem (100%) Fetching: fog-core-1.43.0.gem (100%) Fetching: mini_portile2-2.4.0.gem (100%) Fetching: nokogiri-1.10.9.gem (100%) 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)’! $
For those finding this thread… the tail continues by installing
virt-managerusing this repo: https://github.com/jeffreywildman/homebrew-virt-manager/Once that’s done with
brewyou should start the daemon withvirt-manager -c qemu+ssh://@/system?socket=/var/run/libvirt/libvirt-sock.Maybe troubleshoot:
brew install py2cairo.Good luck!
ccosby’s steps worked for me, i think i am past the ruby error however i get:
Error while connecting to libvirt: Error making a connection to libvirt URI qemu+ssh://192.168.15.127/system?no_verify=1&keyfile=/Users/myuser/.ssh/id_rsa&socket=/var/run/libvirt/libvirt-sock: Call to virConnectOpen failed: internal error: received hangup event on socketAs a easier workaround:
Howevr I didn’t manage to start a VM on OSX anyway
I got it working with the following:
Turns out there is a brew package available, for those who use homebrew.
I managed to work around this issue on my Linux by following this guide: https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt
I hope someone with knowledge of how plugins installation works could patch the code to enable these parameters for MacOS by default. We had at least 3 people confirming the fix and none saying that it would not work.
@ssbarnea I think someone with a Mac to test and verify the exact steps required, I don’t use Mac’s myself, not sure if any of the other maintainers have access to one
Did you port the patches manually to your ruby-libvirt 0.6.0 source tree? The repository from @kontrafiktion is ruby-libvirt 0.5.2, so to install 0.6.0 you need to port the following changes manually: https://github.com/kontrafiktion/ruby-libvirt/compare/bug-1161338 and https://github.com/kontrafiktion/ruby-libvirt/commit/3f768dc492353a143b45c08180fcd690885c2b09 (OSX specific).
You should also make sure that you are installing the local gem and not installing from source the remote one. Instead of
you should try:
(after you did
/opt/vagrant/embedded/bin/rake packageof course).I am running ruby-libvirt 0.6.0 on OS X El Capitan (10.11.3) without an issue.
// Added missing patch.
On High Sierra - 10.13.6
Fails though:
Plugin was built like so:
@mcandre
I can confirm that it doesn’t work on High Sierra + Vagrant 2.0.1 with the same error that you posted. Still works on High Sierra 10.13.1 + Vagrant 2.0.0. I’ll investigate more and see what I find.
Look through https://github.com/hashicorp/vagrant/blob/master/CHANGELOG.md and see if there’s anything you absolutely need from there. If not, 2.0.0 is still available for download.
Same issue with vagrant-libvirt on Mac OSX El Capitan 10.11.6
$ git branch
/opt/vagrant/embedded/include/ruby-2.2.0/ruby/backward/st.h:2:2: warning: use “ruby/st.h” instead of bare “st.h” [-W#warnings] #warning use “ruby/st.h” instead of bare “st.h”
here is the full log --> http://pastebin.ca/3760772
Please retest this against current master which updates fog-libvirt and ruby-libvirt.
You can
git clonethe repo and do agem build vagrant-libvirt.gemspecwhich generates a.gemthat can be installed withvagrant plugin install /path/to/gemSigh