hashicorp/vagrant · error · Vagrant::Errors::CloneMachineNotFound
The clone environment hasn't been created yet. To clone…
Error message
The clone environment hasn't been created yet. To clone from another Vagrantfile, it must already be created with `vagrant up`. It doesn't need to be running. Additionally, the created environment must be started with a provider matching this provider. For example, if you're using VirtualBox, the clone environment must also be using VirtualBox.
What it means
With `config.vm.clone` set, Vagrant loads the master environment and asks for its primary machine under the CURRENT project's provider. CloneMachineNotFound fires when that machine has no id — the master environment exists on disk but its VM was never created (no `vagrant up` run there), or it was created under a different provider so no machine exists for this provider.
Solutions
- Create the master first: `cd <config.vm.clone path> && vagrant up` (it may be halted afterwards; it just needs to exist).
- Ensure provider match: bring the master up with the same provider the clone project uses, e.g. `vagrant up --provider=virtualbox`.
- Then re-run `vagrant up` in the cloning project.
Example fix
# before # clone project: config.vm.clone = "../master"; master never created vagrant up # => CloneMachineNotFound # after cd ../master && vagrant up --provider=virtualbox && vagrant halt cd - && vagrant up
Defensive patterns
Strategy: validation
Validate before calling
# Shell: verify the master env is created for this provider before upping the clone
master="$CLONE_PATH"; provider="virtualbox"
idfile=$(find "$master/.vagrant/machines" -maxdepth 3 -name id -path "*/$provider/*" 2>/dev/null | head -n1)
[ -s "$idfile" ] || { echo "master not created for $provider; run: (cd $master && vagrant up --provider=$provider)"; exit 1; } Prevention
- Document/automate the boot order: bring up (create) the master environment before any project that clones it.
- Keep the master and clone projects on the same provider; encode the provider explicitly with `vagrant up --provider=...`.
- Remember the master only needs to be created, not running — 'halt' after first up is fine.
When it happens
Trigger: `vagrant up` in the cloning project when the master environment's primary machine `.id` is nil: master never booted, master was `vagrant destroy`ed, or master runs VirtualBox while the clone uses another provider (lib/vagrant/action/builtin/prepare_clone.rb:27-30).
Common situations: Forgetting to boot the master first; provider mismatch between the two Vagrantfiles (the error text calls this out); switching providers in the clone project without re-creating the master.
Related errors
- The box is not able to report an address for WinRM to…
- The box you attempted to add doesn't match the provider you…
- The Docker provider is unable to connect the container to…
- The Docker provider was unable to configure networking…
- The "docker" synced folder type can't be used because the …
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/4c38cfcc378d0901.
Report an issue: GitHub.
Appendix: source
Thrown at lib/vagrant/action/builtin/prepare_clone.rb:29
@app = app
@logger = Log4r::Logger.new("vagrant::action::vm::prepare_clone")
end
def call(env)
# If we aren't cloning, then do nothing
if !env[:machine].config.vm.clone
return @app.call(env)
end
# We need to get the machine ID from this Vagrant environment
clone_env = env[:machine].env.environment(
env[:machine].config.vm.clone)
raise Errors::CloneNotFound if !clone_env.root_path
# Get the machine itself
clone_machine = clone_env.machine(
clone_env.primary_machine_name, env[:machine].provider_name)
raise Errors::CloneMachineNotFound if !clone_machine.id
# Set the ID of the master so we know what to clone from
env[:clone_id] = clone_machine.id
env[:clone_machine] = clone_machine
# Continue
@app.call(env)
end
end
end
end
end
View on GitHub (pinned to 35f3160f4a)