hashicorp/vagrant · error · Vagrant::Errors::VMCloneFailure

Creation of the linked clone failed.

Error message

Creation of the linked clone failed.

What it means

When linked_clone is enabled, the Import action clones the master VM/snapshot via driver.import.clone (passing env[:clone_id] and env[:clone_snapshot]) and then checks env[:machine].id. A nil id means the clone produced no registered machine, so Vagrant raises VMCloneFailure — the linked-clone path did not yield a usable VM.

Source

Thrown at plugins/providers/virtualbox/action/import.rb:36

        end

        def clone(env)
          # Do the actual clone
          env[:ui].info I18n.t("vagrant.actions.vm.clone.creating")
          env[:machine].id = env[:machine].provider.driver.clonevm(
            env[:clone_id], env[:clone_snapshot]) do |progress|
            env[:ui].rewriting do |ui|
              ui.clear_line
              ui.report_progress(progress, 100, false)
            end
          end

          # Clear the line one last time since the progress meter doesn't
          # disappear immediately.
          env[:ui].clear_line

          # Flag as erroneous and return if clone failed
          raise Vagrant::Errors::VMCloneFailure if !env[:machine].id

          # Copy the SSH key from the clone machine if we can
          if env[:clone_machine]
            key_path = env[:clone_machine].data_dir.join("private_key")
            if key_path.file?
              FileUtils.cp(
                key_path,
                env[:machine].data_dir.join("private_key"))
            end
          end

          # Continue
          @app.call(env)
        end

        def import(env)
          env[:ui].info I18n.t("vagrant.actions.vm.import.importing",
                               name: env[:machine].box.name)

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Retry once after `vagrant destroy -f` of the half-created machine, to rule out a transient VirtualBox failure
  2. Disable linked clones: set `config.vm.provider 'virtualbox' { |vb| vb.linked_clone = false }` and `vagrant up` again (full clone/import path)
  3. Remove and re-add the box so the master VM and its snapshot are re-imported cleanly (deletes stale clone_id files)
  4. Free disk space on the host and check `VBoxManage list vms` for the master; run the clone manually with VBoxManage for verbose output if it persists

Example fix

# Vagrantfile - before:
config.vm.provider 'virtualbox' do |vb|
  vb.linked_clone = true
end

# after (workaround while master/snapshot is broken):
config.vm.provider 'virtualbox' do |vb|
  vb.linked_clone = false
end
# plus: vagrant box remove <box> && vagrant box add <box> to rebuild the master
Defensive patterns

Strategy: fallback

Validate before calling

# sanity-check the linked-clone master before up
id_file = File.expand_path('~/.vagrant.d/boxes/<box>/<ver>/virtualbox/clone_id')
if File.file?(id_file)
  master = File.read(id_file).chomp
  exists = `VBoxManage list vms`.include?("#{master} ")
  warn 'Master VM missing - linked clone will fail; re-add box' unless exists
end

Try / catch

begin
  env.cli('up')
rescue Vagrant::Errors::VMCloneFailure
  # fall back to full import: linked clone master/snapshot is unusable
  patch_vagrantfile('vb.linked_clone = false')
  retry
end

Prevention

When it happens

Trigger: `vagrant up` with provider config `linked_clone: true` where the clone/import call returns without an id: master VM or its snapshot missing/corrupt, VirtualBox failing the differencing-disk creation silently, or disk space exhaustion during the clone.

Common situations: The master VM recorded in ~/.vagrant.d/boxes/.../clone_id was deleted from VirtualBox while the id file remained; VirtualBox upgraded and differencing disks broke; host disk full; snapshot the master was pinned to was removed.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/d9018ad97a24aa94. Report an issue: GitHub.