{"record":{"id":"a2793baa5b3d2c4d","repo":"hashicorp/vagrant","slug":"this-command-was-not-invoked-properly-the-help-fo-a2793b","errorCode":null,"errorMessage":"This command was not invoked properly. The help for this command is\navailable below.\n\n%{help}","messagePattern":"This command was not invoked properly\\. The help for this command is\navailable below\\.\n\n%(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::CLIInvalidUsage","httpStatus":null,"severity":"error","filePath":"plugins/commands/snapshot/command/save.rb","lineNumber":36,"sourceCode":"            o.separator \"can be restored via `vagrant snapshot restore` at any point in the\"\n            o.separator \"future to get back to this exact machine state.\"\n            o.separator \"\"\n            o.separator \"If no vm-name is given, Vagrant will take a snapshot of\"\n            o.separator \"the entire environment with the same snapshot name.\"\n            o.separator \"\"\n            o.separator \"Snapshots are useful for experimenting in a machine and being able\"\n            o.separator \"to rollback quickly.\"\n\n            o.on(\"-f\", \"--force\", \"Replace snapshot without confirmation\") do |f|\n              options[:force] = f\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          name = argv.pop\n\n          with_target_vms(argv) do |vm|\n            if !vm.provider.capability?(:snapshot_list)\n              raise Vagrant::Errors::SnapshotNotSupported\n            end\n\n            # In this case, no vm name was given, and we are iterating over the\n            # entire environment. If a vm hasn't been created yet, we can't list\n            # its snapshots\n            if vm.id.nil?\n              @env.ui.warn(I18n.t(\"vagrant.commands.snapshot.save.vm_not_created\",\n                                  name: vm.name))\n              next\n            end","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/snapshot/command/save.rb#L18-L54","documentation":"Usage error from `vagrant snapshot save [options] [vm-name] <name>`: after option parsing there were no positional arguments left (missing the new snapshot's name) or more than two. The save command requires a name for the snapshot it creates, so Vagrant raises CLIInvalidUsage with its help text.","triggerScenarios":"`vagrant snapshot save` with no name; three or more positionals (e.g. `vagrant snapshot save default snap1 extra`); the `-f/--force` flag placed where it leaves stray tokens in argv.","commonSituations":"Users expecting an auto-generated snapshot name; scripts passing extra context words after the name; unquoted names containing spaces.","solutions":["Use the exact form: `vagrant snapshot save <name>` or `vagrant snapshot save <vm-name> <name>`","Place `-f/--force` before the name and quote names with spaces","Run `vagrant snapshot save -h` to confirm the layout"],"exampleFix":"# before\nvagrant snapshot save -f\n\n# after\nvagrant snapshot save -f pre-experiment","handlingStrategy":"validation","validationCode":"positional = argv.reject { |a| a.start_with?('-') }\nraise ArgumentError, 'usage: vagrant snapshot save [vm-name] <name>' unless (1..2).cover?(positional.size)\nsystem('vagrant', 'snapshot', 'save', *positional)","typeGuard":null,"tryCatchPattern":"begin\n  command.execute\nrescue Vagrant::Errors::CLIInvalidUsage => e\n  warn e.extra_data[:help]\n  exit 1\nend","preventionTips":["Always provide an explicit snapshot name in scripts","Keep -f/--force before the name","Quote names containing spaces"],"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"}