{"record":{"id":"b24e986469bb5c2d","repo":"hashicorp/vagrant","slug":"this-command-was-not-invoked-properly-the-help-fo","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/autocomplete/command/install.rb","lineNumber":37,"sourceCode":"            o.separator \"\"\n            o.separator \"Available shells: #{Vagrant::Util::InstallCLIAutocomplete::SUPPORTED_SHELLS.keys.join(' ')}\"\n            o.separator \"\"\n            o.separator \"Options:\"\n            o.separator \"\"\n\n            o.on(\"-b\", \"--bash\", \"Install bash autocomplete\") do |c|\n              options[:shells].append(\"bash\")\n            end\n\n            o.on(\"-z\", \"--zsh\", \"Install zsh autocomplete\") do |c|\n              options[:shells].append(\"zsh\")\n            end\n          end\n\n          # Parse the options\n          argv = parse_options(opts)\n          return if !argv\n          raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0\n\n          written_paths = Vagrant::Util::InstallCLIAutocomplete.install(options[:shells])\n          if written_paths && written_paths.length > 0\n            @env.ui.info(I18n.t(\"vagrant.autocomplete.installed\", paths: written_paths.join(\"\\n- \")))\n          else\n            @env.ui.info(I18n.t(\"vagrant.autocomplete.not_installed\"))\n          end\n\n          # Success, exit status 0\n          0\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":19,"sourceCodeEnd":53,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/autocomplete/command/install.rb#L19-L53","documentation":"Raised by `vagrant autocomplete install` when any positional argument remains after option parsing (argv.length > 0). The command configures shell autocomplete purely through flags (-b/--bash, -z/--zsh, ...), so leftover words are treated as a usage mistake and the generated OptionParser help is embedded in the message.","triggerScenarios":"Running `vagrant autocomplete install bash` (passing the shell as a word instead of a flag), or appending any stray argument to the command; parse_options returns the leftovers and the arity check fires.","commonSituations":"Users assuming the shell name is positional (`autocomplete install bash`); copy-paste from older blog posts; shell aliases appending arguments.","solutions":["Pass the shell as a flag: `vagrant autocomplete install --bash` (or -z for zsh)","Run `vagrant autocomplete install --help` to see the accepted flags","Remove any stray positional arguments from scripts"],"exampleFix":"# before\nvagrant autocomplete install bash\n\n# after\nvagrant autocomplete install --bash","handlingStrategy":"validation","validationCode":"# bash: no positional args allowed; shells come from flags\n[ $# -eq 0 ] || { vagrant autocomplete install --help; exit 1; }\nvagrant autocomplete install --bash --zsh","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read `--help` before guessing argument shapes for niche commands","Use flags (--bash/--zsh), never positional words, for autocomplete install","Wrap rarely-used commands in scripts with an arity assert to fail fast"],"tags":["cli","usage","autocomplete","arguments"],"backgroundTag":"cli-invalid-usage","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}