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 uninstall <name> [<name2> ...]` requires at least one positional argument; argv.length < 1 after parsing raises Vagrant::Errors::CLIInvalidUsage with the help text. Each remaining argv entry is uninstalled in sequence through the uninstall action.

Source

Thrown at plugins/commands/plugin/command/uninstall.rb:25

module VagrantPlugins
  module CommandPlugin
    module Command
      class Uninstall < Base
        def execute
          options = {}
          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant plugin uninstall <name> [<name2> <name3> ...] [-h]"

            o.on("--local", "Remove plugin from local project") do |l|
              options[:env_local] = l
            end
          end

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

          # Uninstall the gems
          argv.each do |gem|
            action(Action.action_uninstall, plugin_name: gem, env_local: options[:env_local])
          end

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

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Pass one or more exact plugin names: `vagrant plugin uninstall vagrant-aws`.
  2. Get the exact names from `vagrant plugin list` first.
  3. Add --local when the plugin is installed in the project scope.

Example fix

# before
vagrant plugin uninstall
# after
vagrant plugin uninstall vagrant-aws vagrant-vbguest
Defensive patterns

Strategy: validation

Validate before calling

names = ARGV.reject { |a| a.start_with?('-') }
abort 'usage: vagrant plugin uninstall <name> [...]' if names.empty?
system('vagrant', 'plugin', 'uninstall', *names)

Try / catch

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

Prevention

When it happens

Trigger: Bare `vagrant plugin uninstall`; an empty loop variable in a script so no names are passed; all tokens consumed as flags.

Common situations: Automation that uninstalls a computed list which turns out empty; shell quoting that drops the name.

Related errors


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