{"record":{"id":"5fe5e879b6d394ee","repo":"hashicorp/vagrant","slug":"this-command-was-not-invoked-properly-the-help-fo-5fe5e8","errorCode":null,"errorMessage":"This command was not invoked properly. The help for this command is available below. %{help}","messagePattern":"This command was not invoked properly\\. The help for this command is available below\\. %(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::CLIInvalidUsage","httpStatus":null,"severity":"error","filePath":"plugins/commands/snapshot/command/restore.rb","lineNumber":35,"sourceCode":"          options[:provision_ignore_sentinel] = false\n          options[:snapshot_start] = true\n\n          opts = OptionParser.new do |o|\n            o.banner = \"Usage: vagrant snapshot restore [options] [vm-name] <name>\"\n            o.separator \"\"\n            build_start_options(o, options)\n            o.separator \"Restore a snapshot taken previously with snapshot save.\"\n\n            o.on(\"--no-start\", \"Don't start the snapshot after the restore\") do\n              options[:snapshot_start] = false\n            end\n          end\n\n          # Parse the options\n          argv = parse_options(opts)\n          return if !argv\n          if argv.empty? || argv.length > 2\n            raise Vagrant::Errors::CLIInvalidUsage,\n              help: opts.help.chomp\n          end\n\n          # Validate the provisioners\n          validate_provisioner_flags!(options, argv)\n\n          name = argv.pop\n          options[:snapshot_name] = name\n\n          with_target_vms(argv) do |vm|\n            if !vm.provider.capability?(:snapshot_list)\n              raise Vagrant::Errors::SnapshotNotSupported\n            end\n\n            snapshot_list = vm.provider.capability(:snapshot_list)\n\n            if snapshot_list.include? name\n              vm.action(:snapshot_restore, options)","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/snapshot/command/restore.rb#L17-L53","documentation":"Usage error from `vagrant snapshot restore [options] [vm-name] <name>`: after parsing, zero positional arguments (no snapshot name) or more than two were supplied. Restore needs exactly one snapshot name, optionally preceded by a vm-name, so Vagrant prints help via CLIInvalidUsage instead of restoring an ambiguous target.","triggerScenarios":"`vagrant snapshot restore` with no snapshot name; three or more positionals after parsing; flags such as `--no-start` placed so that optparse leaves extra tokens in argv.","commonSituations":"Users adding `--provision-with` or `--no-start` in the wrong position; scripts written against `vagrant snapshot restore <vm> <name> <extra>` from older tooling; names with spaces unquoted.","solutions":["Use the exact form: `vagrant snapshot restore <name>` or `vagrant snapshot restore <vm-name> <name>`","Put options (`--no-start`, provisioner flags) before the snapshot name and quote names with spaces","Run `vagrant snapshot restore -h` to re-check the argument layout"],"exampleFix":"# before\nvagrant snapshot restore --no-start\n\n# after\nvagrant snapshot restore --no-start clean-state","handlingStrategy":"validation","validationCode":"positional = argv.reject { |a| a.start_with?('-') }\nraise ArgumentError, 'usage: vagrant snapshot restore [vm-name] <name>' unless (1..2).cover?(positional.size)\nsystem('vagrant', 'snapshot', 'restore', *positional)","typeGuard":null,"tryCatchPattern":"begin\n  command.execute\nrescue Vagrant::Errors::CLIInvalidUsage => e\n  warn e.extra_data[:help]\n  exit 1\nend","preventionTips":["Place options like --no-start before the snapshot name","Check positional arity in wrapper scripts before invoking restore","Re-read `vagrant snapshot restore -h` after upgrading Vagrant"],"tags":["vagrant","snapshot","cli","usage"],"backgroundTag":"cli-invalid-usage","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}