{"record":{"id":"4c38cfcc378d0901","repo":"hashicorp/vagrant","slug":"the-clone-environment-hasn-t-been-created-yet-to","errorCode":null,"errorMessage":"The clone environment hasn't been created yet. To clone from\nanother Vagrantfile, it must already be created with `vagrant up`.\nIt doesn't need to be running.\n\nAdditionally, the created environment must be started with a provider\nmatching this provider. For example, if you're using VirtualBox,\nthe clone environment must also be using VirtualBox.","messagePattern":"The clone environment hasn't been created yet\\. To clone from\nanother Vagrantfile, it must already be created with `vagrant up`\\.\nIt doesn't need to be running\\.\n\nAdditionally, the created environment must be started with a provider\nmatching this provider\\. For example, if you're using VirtualBox,\nthe clone environment must also be using VirtualBox\\.","errorType":"exception","errorClass":"Vagrant::Errors::CloneMachineNotFound","httpStatus":null,"severity":"error","filePath":"lib/vagrant/action/builtin/prepare_clone.rb","lineNumber":29,"sourceCode":"          @app = app\n          @logger = Log4r::Logger.new(\"vagrant::action::vm::prepare_clone\")\n        end\n\n        def call(env)\n          # If we aren't cloning, then do nothing\n          if !env[:machine].config.vm.clone\n            return @app.call(env)\n          end\n\n          # We need to get the machine ID from this Vagrant environment\n          clone_env = env[:machine].env.environment(\n            env[:machine].config.vm.clone)\n          raise Errors::CloneNotFound if !clone_env.root_path\n\n          # Get the machine itself\n          clone_machine = clone_env.machine(\n            clone_env.primary_machine_name, env[:machine].provider_name)\n          raise Errors::CloneMachineNotFound if !clone_machine.id\n\n          # Set the ID of the master so we know what to clone from\n          env[:clone_id] = clone_machine.id\n          env[:clone_machine] = clone_machine\n\n          # Continue\n          @app.call(env)\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":11,"sourceCodeEnd":42,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/lib/vagrant/action/builtin/prepare_clone.rb#L11-L42","documentation":"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.","triggerScenarios":"`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).","commonSituations":"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.","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."],"exampleFix":"# before\n# clone project: config.vm.clone = \"../master\"; master never created\nvagrant up   # => CloneMachineNotFound\n\n# after\ncd ../master && vagrant up --provider=virtualbox && vagrant halt\ncd - && vagrant up","handlingStrategy":"validation","validationCode":"# Shell: verify the master env is created for this provider before upping the clone\nmaster=\"$CLONE_PATH\"; provider=\"virtualbox\"\nidfile=$(find \"$master/.vagrant/machines\" -maxdepth 3 -name id -path \"*/$provider/*\" 2>/dev/null | head -n1)\n[ -s \"$idfile\" ] || { echo \"master not created for $provider; run: (cd $master && vagrant up --provider=$provider)\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["vagrant","clone","provider","machine-state"],"backgroundTag":"resource-not-created","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}