Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install vagrant-libvirt on Fedora #1403

Closed
JaneSoo opened this issue Nov 18, 2021 · 15 comments
Closed

Can't install vagrant-libvirt on Fedora #1403

JaneSoo opened this issue Nov 18, 2021 · 15 comments

Comments

@JaneSoo
Copy link

JaneSoo commented Nov 18, 2021

Error message showing that I don't have libvirt on my distribution while I already installed:
vagrant plugin install vagrant-libvirt

  • Error message:
Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
Building native extensions. This could take a while...
Vagrant failed to install the requested plugin because it depends
on a library which is not currently installed on this system. The
following library is required by the 'vagrant-libvirt' plugin:

  libvirt

Please install the library and then run the command again.

Steps to reproduce the error:

Error message:

Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
Building native extensions. This could take a while...
Vagrant failed to install the requested plugin because it depends
on a library which is not currently installed on this system. The
following library is required by the 'vagrant-libvirt' plugin:

  libvirt

Please install the library and then run the command again.

Does anyone know if I miss something?

@electrofelix
Copy link
Contributor

For Fedora I'd recommending using the following in order of preference:

I believe the problem you are seeing is because there is a conflict between the libraries bundled in upstream vagrant and those that the libvirt library is linked against, consequently you see this issue.

The script reference in option 3 takes care of patching the upstream vagrant with builds of libraries that should work to allow ruby-libvirt be linked to libvirt when being installed. But it means use of sudo to modify some of the libraries bundled with the upstream vagrant, so there could be breakage further down.

That install script reference is my attempt to get closer to regularly testing the latest from this repo against the various distros. I don't yet have it running automatically, but testing last weekend it was able to correctly install upstream vagrant and patch it to allow vagrant-libvirt to be installed directly on fedora 33 & 34. I'm also hoping to work out the steps for fedora to use the distro vagrant, combined with distro ruby-libvirt/fog-libvirt packages installed in a way that means only vagrant-libvirt need come from a gem and be installed by vagrant itself to give access to the latest features without the problems installing it, but that's still a work in progress.

In general though, I'd recommend using the distro packaged versions where possible.

If the distro packages work for you, easier to stay with them, otherwise if you need the latest vagrant-libvirt you'll possibly want to consider the docker/podman image, or using that install script and accepting having it modify vagrant itself.

@electrofelix
Copy link
Contributor

Actually the following instructions should work to get the latest vagrant-libvirt plugin installed with the distro vagrant package:

sudo dnf update
sudo dnf install @virtualization vagrant-libvirt
sudo systemctl enable --now libvirtd
sudo dnf remove --noautoremove vagrant-libvirt
sudo usermod -a -G libvirt vagrant
vagrant plugin install vagrant-libvirt
exec sg libvirt newgrp `id -gn`

Keep in mind this uses the system libvirt connection, while the default package for fedora uses the session connection. Only difference is you'll need to export LIBVIRT_DEFAULT_URI=qemu:///session before doing vagrant up and you don't need to be in the group if you want to use the session approach.

However that might be a lot easier than messing around with the upstream vagrant package.

@JaneSoo
Copy link
Author

JaneSoo commented Nov 19, 2021

@electrofelix I have tried your second instruction but it didn't seem to work for me. I got the same error. I will try the first approach later. Thanks a lot!

@electrofelix
Copy link
Contributor

@JaneSoo can you share what you saw when trying to use those commands?

I was on a pristine fedora 34 VM when I checked that, so you might have to purge both the upstream vagrant and anything relating to the plugins ~/.vagrant.d/ to get it to work if you've already tried installing some bits as otherwise can end up with issues with vagrant trying to deal with two versions of the same gem and picking the wrong one.

@JaneSoo
Copy link
Author

JaneSoo commented Nov 19, 2021

@electrofelix All commands run successfully but vagrant plugin install vagrant-libvirt still output this error:

Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
Building native extensions. This could take a while...
Vagrant failed to install the requested plugin because it depends
on a library which is not currently installed on this system. The
following library is required by the 'vagrant-libvirt' plugin:

  libvirt

Please install the library and then run the command again.

I am on Fedora 35

@electrofelix
Copy link
Contributor

Unfortunately there isn't a fedora 35 box published at https://app.vagrantup.com for me to use to experiment to compare, so I'm stuck checking install steps with fedora 34 for the moment.

Worth using VAGRANT_LOG=debug vagrant plugin install vagrant-libvirt 2>&1 | tee vagrant.log and then attach the log file to this issue as I might be able to see what is happening and correct the steps. If it's possible to get the latest version installed with the distro packaged plugin it's likely to have a few less issues as it should be slightly better integrated with the rest of your system.

@JaneSoo
Copy link
Author

JaneSoo commented Nov 19, 2021

Here is the log:

vagrant.log

@electrofelix
Copy link
Contributor

I can see it's still using the upstream vagrant rather than the distro vagrant. Can you uninstall the vagrant package completely and try the instructions again for the distro based one. There is probably a setting that would have removed it and installed the distro one instead, just not sure what it would be.

@JaneSoo
Copy link
Author

JaneSoo commented Nov 19, 2021

I am confused. Isn't the instruction below for distro based:

sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
sudo dnf -y install vagrant

@electrofelix
Copy link
Contributor

That installs the vagrant package as built by hashicorp, unfortunately that causes issues with vagrant-libvirt due to incompatible library versions. If you want to use that package you will need to use the script I've linked previously which modifies the files installed by the hashicorp package.

However I've now worked out how to get the latest vagrant-libvirt to be installable with the fedora packaged vagrant, which is the subsequent instructions:

sudo dnf update
sudo dnf install @virtualization vagrant-libvirt
sudo systemctl enable --now libvirtd
sudo dnf remove --noautoremove vagrant-libvirt
sudo usermod -a -G libvirt vagrant
vagrant plugin install vagrant-libvirt
exec sg libvirt newgrp `id -gn`

But for that to work it requires removing the hashicorp packaged vagrant to allow the fedora packaged vagrant to be installed. Otherwise it will skip installing the fedora package as there is already a vagrant package installed.

@JaneSoo
Copy link
Author

JaneSoo commented Nov 19, 2021

I got it. I keep uninstalling and installing vagrant with distro again but it always picks up the one from hashicorp because I have the repo enabled. I disable harshicorp repo and follow your step above. It works perfectly. Thanks a lot @electrofelix

@JaneSoo JaneSoo closed this as completed Nov 19, 2021
@electrofelix
Copy link
Contributor

I hadn't considered that it would keep using the upstream package, thanks for sharing that, I'll have to keep that in mind for any instructions I share.

Hopefullly something as simple as the following would work to switch to the distro packaged verison:

dnf config-manager --set-disabled hashicorp

@electrofelix
Copy link
Contributor

Minor correction to the above instructions, you probably want to run the following to ensure an explicit install of the vagrant-libvirt dependencies so that fedora doesn't think it can automatically remove them subsequently.

dependencies=$(sudo dnf repoquery --qf "%{name}" $(for dep in $(sudo dnf repoquery --depends vagrant-libvirt 2>/dev/null | cut -d' ' -f1); do echo "--whatprovides ${dep} "; done) 2>/dev/null)
sudo dnf mark install ${dependencies}

Or change the instruction sudo dnf install @virtualization vagrant-libvirt to:

dependencies=$(sudo dnf repoquery --qf "%{name}" $(for dep in $(sudo dnf repoquery --depends vagrant-libvirt 2>/dev/null | cut -d' ' -f1); do echo "--whatprovides ${dep} "; done) 2>/dev/null)
sudo dnf install @virtualization ${dependencies}

@JaneSoo
Copy link
Author

JaneSoo commented Nov 20, 2021

Get to learn something new, thanks

@GoranSustekJr
Copy link

Try to install these two pacakges

sudo yum -y install libvirt-devel
sudo yum -y groupinstall "Development Tools"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants