Unable to use new Vagrant install - Error while connecting to libvirt
Asked Answered
C

4

11

Regardless if I have a Vagrant file or if one doesn't exist and I create my own with vagrant init (which works btw) I get an error when trying to do this:

vagrant up

The error is:

1: from /usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.0.43/lib/vagrant-libvirt/driver.rb:40:in `connection'
/usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.0.43/lib/vagrant-libvirt/driver.rb:43:in `rescue in connection': Error while connecting to libvirt: 
Error making a connection to libvirt URI qemu:///system?no_verify=1&keyfile=/home/michael/.ssh/id_rsa: (VagrantPlugins::ProviderLibvirt::Errors::FogLibvirtConnectionError)
Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
Error while connecting to libvirt: Error making a connection to libvirt URI qemu:///system?no_verify=1&keyfile=/home/michael/.ssh/id_rsa:
Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory

This is on Ubuntu 18.04

Comeau answered 2/5, 2019 at 13:27 Comment(0)
C
5

Two things are needed:

  1. You need to specifiy a provider
  2. That provider needs to be setup

For 2 (setting up the provider) you can do (for example)

sudo apt-get install virtualbox

Then, for 1 (setting up the box from them)

vagrant up --provider virtualbox
Comeau answered 2/5, 2019 at 13:39 Comment(1)
FWIW on my MacBook this worked (I already had virtualbox but the --provider virtualbox did it). For the record my error was Error while connecting to Libvirt: Error making a connection to libvirt URI qemu:///system: Call to virConnectOpen failed: Failed to connect socket to '/usr/local/var/run/libvirt/virtqemud-sock': No such file or directoryHeaver
A
4

The problem is that libvirt provider is missed. If you want to use libvirt as the provider, please install it with:

sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils

and then, with the default libvirt configuration, the vagrant needs the privilege to create a kvm machine:

sudo vagrant up
Almeda answered 30/3, 2023 at 6:16 Comment(1)
I can think of no good reason to run vagrant as root (under sudo), and lots of good reasons not to. Instead of running under sudo, I recommend folks (a) make sure they're in the 'libvirt' group (which happened automatically for me, when installing the above with sudo apt install), and (b) make sure to start a new login shell (e.g. with sudo su - $USER -- which yes, uses sudo, but doesn't leave you logged in as root, or just log out and back in), and then a mere vagrant up should work (it did for me, anyway).Majewski
S
2

try

vagrant up --provider virtualbox

Then if still not good. check vagrant and virtualbox version compatibility

Sfumato answered 18/4, 2020 at 17:13 Comment(0)
T
0

For VMWARE workstation, follow the installation instructions here.

Then run vagrant up --provider vmware_desktop

Timberwork answered 19/2, 2022 at 0:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.