Gem::LoadError: can't activate vagrant-libvirt-0.2.1, already activated vagrant-libvirt-0.0.45

I’ve followed the steps to install Trellis on local Ubuntu (Kubuntu) 20.04

On the ‘vagrant up’ command, I’m getting the following error:

Gem::LoadError: can’t activate vagrant-libvirt-0.2.1, already activated vagrant-libvirt-0.0.45

Vagrant 2.2.6
vagrant-libvirt (0.0.45, system)
VirtualBox Versión 6.1.10_Ubuntu r138449

I’ve tried vagrant plugin update with result All plugins are up to date.

Is anyone able to help?

Thank you

What plugins do you have installed? You can run vagrant plugin list

Unfortunately I doubt we’ll be able to help much since this is likely a Vagrant issue unrelated to Trellis.

vagrant plugin list
vagrant-libvirt (0.0.45, system)

vagrant up

Installing plugin vagrant-bindfs
Vagrant failed to initialize at a very early stage:

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: /home/ako/Code/wordpress.local/trellis/Vagrantfile
Line number: 0
Message: Gem::LoadError: can't activate vagrant-libvirt-0.2.1, already activated vagrant-libvirt-0.0.45

My Vagrantfile

ANSIBLE_PATH = __dir__ # absolute path to Ansible directory on host machine
ANSIBLE_PATH_ON_VM = '/home/vagrant/trellis'.freeze # absolute path to Ansible directory on virtual machine

require File.join(ANSIBLE_PATH, 'lib', 'trellis', 'vagrant')
require File.join(ANSIBLE_PATH, 'lib', 'trellis', 'config')
require 'yaml'

vconfig = YAML.load_file("#{ANSIBLE_PATH}/vagrant.default.yml")

if File.exist?("#{ANSIBLE_PATH}/vagrant.local.yml")
  local_config = YAML.load_file("#{ANSIBLE_PATH}/vagrant.local.yml")
  vconfig.merge!(local_config) if local_config

ensure_plugins(vconfig.fetch('vagrant_plugins')) if vconfig.fetch('vagrant_install_plugins')

trellis_config = ANSIBLE_PATH)

Vagrant.require_version '>= 2.1.0'

Vagrant.configure('2') do |config| = vconfig.fetch('vagrant_box')
  config.vm.box_version = vconfig.fetch('vagrant_box_version')
  config.ssh.forward_agent = true
  config.vm.post_up_message = post_up_message

  # Fix for: "stdin: is not a tty"
  # = %(bash -c 'BASH_ENV=/etc/profile exec bash')

  # Required for NFS to work
  if vconfig.fetch('vagrant_ip') == 'dhcp' :private_network, type: 'dhcp', hostsupdater: 'skip'

    cached_addresses = {}
    config.hostmanager.ip_resolver = proc do |vm|
      if cached_addresses[].nil?
        if vm.communicate.ready?
          vm.communicate.execute("hostname -I | cut -d ' ' -f 2") do |_type, contents|
            cached_addresses[] = contents.split("\n").first[/(\d+\.\d+\.\d+\.\d+)/, 1]
  else :private_network, ip: vconfig.fetch('vagrant_ip'), hostsupdater: 'skip'

  main_hostname, *hostnames = trellis_config.site_hosts_canonical
  config.vm.hostname = main_hostname

  if Vagrant.has_plugin?('vagrant-hostmanager') && !trellis_config.multisite_subdomains?
    redirects = trellis_config.site_hosts_redirects

    config.hostmanager.enabled = true
    config.hostmanager.manage_host = true
    config.hostmanager.aliases = hostnames + redirects
  elsif Vagrant.has_plugin?('landrush') && trellis_config.multisite_subdomains?
    config.landrush.enabled = true
    config.landrush.tld = trellis_config.site_hosts_canonical.reject { |host| host.end_with?(".#{main_hostname}") }
    hostnames.each { |host| host, vconfig.fetch('vagrant_ip') }
    fail_with_message "vagrant-hostmanager missing, please install the plugin with this command:\nvagrant plugin install vagrant-hostmanager\n\nOr install landrush for multisite subdomains:\nvagrant plugin install landrush"

  bin_path = File.join(ANSIBLE_PATH_ON_VM, 'bin')

  vagrant_mount_type = vconfig.fetch('vagrant_mount_type')

  extra_options = if vagrant_mount_type == 'smb'
      smb_username: vconfig.fetch('vagrant_smb_username', nil),
      smb_password: vconfig.fetch('vagrant_smb_password', nil),

  if vagrant_mount_type != 'nfs' || Vagrant::Util::Platform.wsl? || ( && !Vagrant.has_plugin?('vagrant-winnfsd'))
    vagrant_mount_type = nil if vagrant_mount_type == 'nfs'
    trellis_config.wordpress_sites.each_pair do |name, site|
      config.vm.synced_folder local_site_path(site), remote_site_path(name, site), owner: 'vagrant', group: 'www-data', mount_options: mount_options(vagrant_mount_type, dmode: 776, fmode: 775), type: vagrant_mount_type, **extra_options

    config.vm.synced_folder ANSIBLE_PATH, ANSIBLE_PATH_ON_VM, mount_options: mount_options(vagrant_mount_type, dmode: 755, fmode: 644), type: vagrant_mount_type, **extra_options
    config.vm.synced_folder File.join(ANSIBLE_PATH, 'bin'), bin_path, mount_options: mount_options(vagrant_mount_type, dmode: 755, fmode: 755), type: vagrant_mount_type, **extra_options
  elsif !Vagrant.has_plugin?('vagrant-bindfs')
    fail_with_message "vagrant-bindfs missing, please install the plugin with this command:\nvagrant plugin install vagrant-bindfs"
    trellis_config.wordpress_sites.each_pair do |name, site|
      config.vm.synced_folder local_site_path(site), nfs_path(name), type: 'nfs'
      config.bindfs.bind_folder nfs_path(name), remote_site_path(name, site), u: 'vagrant', g: 'www-data', o: 'nonempty'

    config.vm.synced_folder ANSIBLE_PATH, '/ansible-nfs', type: 'nfs'
    config.bindfs.bind_folder '/ansible-nfs', ANSIBLE_PATH_ON_VM, o: 'nonempty', p: '0644,a+D'
    config.bindfs.bind_folder bin_path, bin_path, perms: '0755'

  vconfig.fetch('vagrant_synced_folders', []).each do |folder|
    options = {
      type: folder.fetch('type', 'nfs'),
      create: folder.fetch('create', false),
      mount_options: folder.fetch('mount_options', [])

    destination_folder = folder.fetch('bindfs', true) ? nfs_path(folder['destination']) : folder['destination']

    config.vm.synced_folder folder['local_path'], destination_folder, options

    if folder.fetch('bindfs', true)
      config.bindfs.bind_folder destination_folder, folder['destination'], folder.fetch('bindfs_options', {})

  provisioner = local_provisioning? ? :ansible_local : :ansible
  provisioning_path = local_provisioning? ? ANSIBLE_PATH_ON_VM : ANSIBLE_PATH

  # Fix for
  if local_provisioning?
    config.vm.provision 'shell', inline: <<~SHELL
      sudo apt-get update -y -qq &&
      sudo dpkg-reconfigure libc6 &&
      export DEBIAN_FRONTEND=noninteractive &&
      sudo -E apt-get -q --option \"Dpkg::Options::=--force-confold\" --assume-yes install libssl1.1

  config.vm.provision provisioner do |ansible|
    if local_provisioning?
      ansible.install_mode = 'pip'
      if Vagrant::VERSION >= '2.2.5'
        # Fix for
        ansible.pip_install_cmd = 'curl | sudo python'
      ansible.provisioning_path = provisioning_path
      ansible.version = vconfig.fetch('vagrant_ansible_version')

    ansible.compatibility_mode = '2.0'
    ansible.playbook = File.join(provisioning_path, 'dev.yml')
    ansible.galaxy_role_file = File.join(provisioning_path, 'galaxy.yml') unless vconfig.fetch('vagrant_skip_galaxy') || ENV['SKIP_GALAXY']
    ansible.galaxy_roles_path = File.join(provisioning_path, 'vendor/roles')

    ansible.groups = {
      'web' => ['default'],
      'development' => ['default']

    ansible.tags = ENV['ANSIBLE_TAGS']
    ansible.extra_vars = { 'vagrant_version' => Vagrant::VERSION }

    if (vars = ENV['ANSIBLE_VARS'])
      extra_vars = Hash[vars.split(',').map { |pair| pair.split('=') }]

    if !
      config.trigger.after :up do |trigger|
        # Add Vagrant ssh-config to ~/.ssh/config = "Adding vagrant ssh-config for #{main_hostname } to ~/.ssh/config"
        trigger.ruby do

  # VirtualBox settings
  config.vm.provider 'virtualbox' do |vb| = config.vm.hostname
    vb.customize ['modifyvm', :id, '--cpus', vconfig.fetch('vagrant_cpus')]
    vb.customize ['modifyvm', :id, '--memory', vconfig.fetch('vagrant_memory')]
    vb.customize ['modifyvm', :id, '--ioapic', vconfig.fetch('vagrant_ioapic', 'on')]

    # Fix for slow external network connections
    vb.customize ['modifyvm', :id, '--natdnshostresolver1', vconfig.fetch('vagrant_natdnshostresolver', 'on')]
    vb.customize ['modifyvm', :id, '--natdnsproxy1', vconfig.fetch('vagrant_natdnsproxy', 'on')]

  # VMware Workstation/Fusion settings
  %w(vmware_fusion vmware_workstation).each do |provider|
    config.vm.provider provider do |vmw|
      vmw.vmx['displayName'] = config.vm.hostname
      vmw.vmx['numvcpus'] = vconfig.fetch('vagrant_cpus')
      vmw.vmx['memsize'] = vconfig.fetch('vagrant_memory')

  # Parallels settings
  config.vm.provider 'parallels' do |prl| = config.vm.hostname
    prl.cpus = vconfig.fetch('vagrant_cpus')
    prl.memory = vconfig.fetch('vagrant_memory')
    prl.update_guest_tools = true

  # Hyper-V settings
  config.vm.provider 'hyperv' do |h|
    h.vmname = config.vm.hostname
    h.cpus = vconfig.fetch('vagrant_cpus')
    h.memory = vconfig.fetch('vagrant_memory')
    h.enable_virtualization_extensions = true
    h.linked_clone = true

Unfortunately I doubt we’ll be able to help much since this is likely a Vagrant issue unrelated to Trellis.

Okay, thanks a lot anyway. I’ll look it up like a Vagrant error.

The error disappears if I downgrade Vagrant from 2.2.6 to 2.1.5.
But the version of Virtualbox in Ubuntu 20.04, 6.1, is not supported by version 2.1.5 of Vagrant.

I tried to install Virtualbox 5.2. But I have come across a dependency that I cannot fix: the version of the libvpx package. I have installed v6 and Virtualbox 5.2 need v5.

After reinstalling Vagrant 2.2.6 and Virtualbox 6.1, evertything work correctly. :roll_eyes:

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.