{"record":{"id":"0e6133edfbe47ae0","repo":"hashicorp/vagrant","slug":"this-command-was-not-invoked-properly-the-help-fo-0e6133","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/delete.rb","lineNumber":23,"sourceCode":"\nmodule VagrantPlugins\n  module CommandSnapshot\n    module Command\n      class Delete < Vagrant.plugin(\"2\", :command)\n        def execute\n          options = {}\n\n          opts = OptionParser.new do |o|\n            o.banner = \"Usage: vagrant snapshot delete [options] [vm-name] <name>\"\n            o.separator \"\"\n            o.separator \"Delete a snapshot taken previously with snapshot save.\"\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          name = argv.pop\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_delete, snapshot_name: name)\n            else\n              raise Vagrant::Errors::SnapshotNotFound,\n                snapshot_name: name,\n                machine: vm.name.to_s\n            end","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/snapshot/command/delete.rb#L5-L41","documentation":"Usage error from `vagrant snapshot delete [options] [vm-name] <name>`: after option parsing, the leftover positional arguments were empty (missing the snapshot name) or more than two. The command raises CLIInvalidUsage with its help text rather than guessing which snapshot to delete.","triggerScenarios":"`vagrant snapshot delete` with no positional argument; `vagrant snapshot delete snap1 extra` (three positionals after a vm-name is also included); an unrecognized flag left in argv so the name lands in the wrong position.","commonSituations":"Users expecting `vagrant snapshot delete` to prompt or delete the newest snapshot; scripts written with an extra flag after the name that optparse does not consume; snapshot names with unescaped spaces.","solutions":["Use the exact form: `vagrant snapshot delete <name>` or `vagrant snapshot delete <vm-name> <name>`","Run `vagrant snapshot delete -h` to confirm the positional layout for your Vagrant version","Quote snapshot names containing spaces and remove stray arguments from the command line"],"exampleFix":"# before\nvagrant snapshot delete\nvagrant snapshot delete default snap1 extra\n\n# after\nvagrant snapshot delete snap1\nvagrant snapshot delete default snap1","handlingStrategy":"validation","validationCode":"positional = argv.reject { |a| a.start_with?('-') }\nraise ArgumentError, 'usage: vagrant snapshot delete [vm-name] <name>' unless (1..2).cover?(positional.size)\nsystem('vagrant', 'snapshot', 'delete', *positional)","typeGuard":null,"tryCatchPattern":"begin\n  command.execute\nrescue Vagrant::Errors::CLIInvalidUsage => e\n  warn e.extra_data[:help]\n  exit 1\nend","preventionTips":["Validate positional argument count before shelling out to snapshot subcommands","Quote snapshot names that contain spaces","Parse `vagrant snapshot delete -h` when writing wrappers so arity matches the installed version"],"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"}