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

`vagrant plugin list` takes no positional arguments; only the --local stub flag (kept so Vagrantfile loading works) is accepted. Any leftover argv (argv.length > 0) raises Vagrant::Errors::CLIInvalidUsage with the help text.

Source

Thrown at plugins/commands/plugin/command/list.rb:23

require_relative "base"

module VagrantPlugins
  module CommandPlugin
    module Command
      class List < Base
        def execute
          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant plugin list [-h]"

            # Stub option to allow Vagrantfile loading
            o.on("--local", "Include local project plugins"){|_|}
          end

          # Parse the options
          argv = parse_options(opts)
          return if !argv
          raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0

          # List the installed plugins
          action(Action.action_list)

          # Success, exit status 0
          0
        end
      end
    end
  end
end

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Run bare: `vagrant plugin list`.
  2. Filter with shell tools instead: `vagrant plugin list | grep vagrant-aws`.
  3. Use `vagrant plugin list --local` to include project-local plugins.

Example fix

# before
vagrant plugin list vagrant-aws
# after
vagrant plugin list | grep vagrant-aws
Defensive patterns

Strategy: validation

Validate before calling

abort 'vagrant plugin list takes no positional arguments' unless ARGV.reject { |a| a.start_with?('-') }.empty?
system('vagrant', 'plugin', 'list')

Try / catch

begin
  Vagrant::Environment.new.cli(['plugin', 'list'])
rescue Vagrant::Errors::CLIInvalidUsage => e
  warn e.message
  exit 1
end

Prevention

When it happens

Trigger: `vagrant plugin list vagrant-aws` or any positional word after the subcommand; flags are fine, bare words are not.

Common situations: Trying to filter or query a single plugin the way `gem list` or `npm ls` allow; scripts passing a plugin name for a 'does it exist' check.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/c73b67899384be74. Report an issue: GitHub.