I am on an Apple Silicon M1. I want to use libvirt with vagrant.
I got installed:
❯ brew -v 132.248.234.96 ─╯
Homebrew 3.6.20
❯ vagrant -v 132.248.234.96 ─╯
Vagrant 2.3.4
❯ /opt/vagrant/embedded/bin/ruby --version 132.248.234.96 ─╯
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-darwin19]
echo 'security_driver = "none"' >> /opt/homebrew/etc/libvirt/qemu.conf
echo "dynamic_ownership = 0" >> /opt/homebrew/etc/libvirt/qemu.conf
echo "remember_owner = 0" >> /opt/homebrew/etc/libvirt/qemu.conf
❯ virsh -v 132.248.234.96 ─╯
9.0.0
I unsuccessfully have followed this Alex Scheitlin GitHub tutorial to install libvirt, but right after executing the following command:
brew install --build-from-source --debug ./libvirt.rb
I get the following error:
❯ brew install --build-from-source --debug ./libvirt.rb 132.248.234.96 ─╯
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::FromPathLoader): loading /Users/me/libvirt.rb
Error: Failed to load cask: ./libvirt.rb
Cask 'libvirt' is unreadable: wrong constant name #<Class:0x0000000149e072f8>
Warning: Treating ./libvirt.rb as a formula.
Error: libvirt 9.0.0 is already installed
To install 7.10.0, first run:
brew unlink libvirt
I went on trying to install the vagrant-libvirt plugin, and I also get the following error:
❯ vagrant plugin install vagrant-libvirt 132.248.234.96 ─╯
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/me/.vagrant.d/gems/2.7.6/gems/ruby-libvirt-0.8.0/ext/libvirt
/opt/vagrant/embedded/bin/ruby -I /opt/vagrant/embedded/lib/ruby/2.7.0 -r ./siteconf20230123-4745-9mjub.rb extconf.rb
Looking for libvirt in /opt/homebrew/opt/libvirt/include and /opt/homebrew/opt/libvirt/lib
checking for virConnectOpen() in -lvirt... no
*** 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)
--with-libvirt-include
--with-libvirt-lib
--with-virt-dir
--without-virt-dir
--with-virt-include
--without-virt-include=${virt-dir}/include
--with-virt-lib
--without-virt-lib=${virt-dir}/lib
--with-virtlib
--without-virtlib
extconf.rb:44:in `<main>': No working libvirt installation found (RuntimeError)
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/me/.vagrant.d/gems/2.7.6/extensions/x86_64-darwin-19/2.7.0/ruby-libvirt-0.8.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/me/.vagrant.d/gems/2.7.6/gems/ruby-libvirt-0.8.0 for inspection.
Results logged to /Users/me/.vagrant.d/gems/2.7.6/extensions/x86_64-darwin-19/2.7.0/ruby-libvirt-0.8.0/gem_make.out
How do I fix it?