hashicorp/vagrant · error · Vagrant::Errors::CLIInvalidUsage
This command was not invoked properly. The help for this com
Error message
This command was not invoked properly. The help for this command is
available below.
%{help} What it means
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.
Source
Thrown at plugins/commands/autocomplete/command/install.rb:37
o.separator ""
o.separator "Available shells: #{Vagrant::Util::InstallCLIAutocomplete::SUPPORTED_SHELLS.keys.join(' ')}"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-b", "--bash", "Install bash autocomplete") do |c|
options[:shells].append("bash")
end
o.on("-z", "--zsh", "Install zsh autocomplete") do |c|
options[:shells].append("zsh")
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
written_paths = Vagrant::Util::InstallCLIAutocomplete.install(options[:shells])
if written_paths && written_paths.length > 0
@env.ui.info(I18n.t("vagrant.autocomplete.installed", paths: written_paths.join("\n- ")))
else
@env.ui.info(I18n.t("vagrant.autocomplete.not_installed"))
end
# Success, exit status 0
0
end
end
end
end
end
View on GitHub (pinned to 35f3160f4a)
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
Example fix
# before vagrant autocomplete install bash # after vagrant autocomplete install --bash
Defensive patterns
Strategy: validation
Validate before calling
# bash: no positional args allowed; shells come from flags
[ $# -eq 0 ] || { vagrant autocomplete install --help; exit 1; }
vagrant autocomplete install --bash --zsh Prevention
- 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
When it happens
Trigger: 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.
Common situations: Users assuming the shell name is positional (`autocomplete install bash`); copy-paste from older blog posts; shell aliases appending arguments.
Related errors
- This command was not invoked properly. The help for this com
- This command was not invoked properly. The help for this com
- This command was not invoked properly. The help for this com
- This command was not invoked properly. The help for this com
- This command was not invoked properly. The help for this com
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/b24e986469bb5c2d.
Report an issue: GitHub.