{"record":{"id":"97b96ed907a5f5f1","repo":"hashicorp/vagrant","slug":"could-not-run-remote-script-on-guest-because-it-do","errorCode":null,"errorMessage":"Could not run remote script on guest because it does not exist.","messagePattern":"Could not run remote script on guest because it does not exist\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/vagrant/plugin/v2/trigger.rb","lineNumber":306,"sourceCode":"              @logger.debug(\"Trigger run encountered an error. Halting on error...\")\n              raise e\n            else\n              @logger.debug(\"Trigger run encountered an error. Continuing on anyway...\")\n              @ui.warn(I18n.t(\"vagrant.trigger.on_error_continue\"))\n            end\n          end\n        end\n\n        # Runs a script on the guest\n        #\n        # @param [ShellProvisioner/Config] config A Shell provisioner config\n        def run_remote(config, on_error, exit_codes)\n          if !@machine\n            # machine doesn't even exist.\n            if on_error == :halt\n              raise Errors::TriggersGuestNotExist\n            else\n              @ui.warn(I18n.t(\"vagrant.errors.triggers_guest_not_exist\"))\n              @ui.warn(I18n.t(\"vagrant.trigger.on_error_continue\"))\n              return\n            end\n          elsif @machine.state.id != :running\n            if on_error == :halt\n              raise Errors::TriggersGuestNotRunning,\n                machine_name: @machine.name,\n                state: @machine.state.id\n            else\n              @machine.ui.error(I18n.t(\"vagrant.errors.triggers_guest_not_running\",\n                                        machine_name: @machine.name,\n                                        state: @machine.state.id))\n              @machine.ui.warn(I18n.t(\"vagrant.trigger.on_error_continue\"))\n              return\n            end\n          end\n\n          prov = VagrantPlugins::Shell::Provisioner.new(@machine, config)","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/lib/vagrant/plugin/v2/trigger.rb#L288-L324","documentation":"run_remote executes a shell-provisioner config on the guest (trigger option run_remote). When @machine is nil — the environment has no machine — there is nothing to run on: with on_error :halt it raises Errors::TriggersGuestNotExist; otherwise it warns with the shared triggers_guest_not_exist text ('Could not run remote script on guest because it does not exist.') plus the continue warning, then returns. The message is the locale text for this condition.","triggerScenarios":"A trigger with run_remote = { inline: ... } firing in a context where the machine doesn't exist yet or anymore: `vagrant triggers run` outside an up'd environment, destroy-time triggers, or before-create lifecycle points — with on_error != :halt downgrading the raise to this warning.","commonSituations":"Guest triggers scoped to commands that run before creation or after destruction; running standalone `vagrant triggers run` for testing; shared Vagrantfiles where guest triggers fire on machines never booted.","solutions":["Create/boot the machine first (vagrant up) so run_remote has a target","Scope guest triggers to lifecycle points where the machine exists, e.g. after :up rather than before :up","Use host-side run triggers for commands that must fire regardless of machine state","Accept the warning if nonexistence is expected and harmless in your flow"],"exampleFix":"# before\nconfig.trigger.before :destroy do |t|\n  t.run_remote = { inline: \"echo bye\" }  # machine gone at destroy time\nend\n\n# after\nconfig.trigger.before :destroy do |t|\n  t.run = { inline: \"echo bye from host\" }  # host-side, always runnable\nend","handlingStrategy":"validation","validationCode":"# guard guest triggers on machine existence in tooling\nreturn if machine.nil? || machine.state.id == :not_created","typeGuard":"def guest_trigger_runnable?(machine)\n  !machine.nil? && machine.state.id == :running\nend","tryCatchPattern":"begin\n  trigger.run_remote(config, :halt, exit_codes)\nrescue Vagrant::Errors::TriggersGuestNotExist\n  ui.warn(\"skipping guest trigger: machine does not exist (not created yet)\")\nend","preventionTips":["Scope run_remote triggers to after :up or other points where the machine exists","Use host-side run triggers for must-fire commands","When testing triggers standalone, boot the machine first or expect this warning"],"tags":["triggers","guest","machine-not-created","warning","run-remote"],"backgroundTag":"guest-machine-not-created","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}