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 repair` accepts only the --local flag and no positional arguments; argv.length > 0 after parsing raises Vagrant::Errors::CLIInvalidUsage with the help text. Repair rebuilds the installed plugin set's gem dependencies, so it never takes plugin names.

Source

Thrown at plugins/commands/plugin/command/repair.rb:26

module VagrantPlugins
  module CommandPlugin
    module Command
      class Repair < Base
        def execute
          options = {}

          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant plugin repair [-h]"

            o.on("--local", "Repair plugins in 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 > 0

          if Vagrant::Plugin::Manager.instance.local_file
            action(Action.action_repair_local, env: @env)
          end

          # Attempt to repair installed plugins
          action(Action.action_repair, options)

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

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Run bare: `vagrant plugin repair`.
  2. Add `--local` to also repair project-local plugins.
  3. If one plugin stays broken, uninstall and reinstall it individually.

Example fix

# before
vagrant plugin repair vagrant-aws
# after
vagrant plugin repair            # add --local for project plugins
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

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

Prevention

When it happens

Trigger: Any positional token: `vagrant plugin repair vagrant-aws`, or a stray word where `--local` was intended.

Common situations: Assuming repair targets one broken plugin; habit from other package managers that take package operands.

Related errors


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