hashicorp/vagrant · error · Vagrant::Errors::ConfigInvalid

There are errors in the configuration of this machine. Pleas

Error message

There are errors in the configuration of this machine. Please fix the following errors and try again: %{errors}

What it means

When `vagrant plugin install` is run with no positional names and the env-local flag, Vagrant first validates the environment's Vagrantfile via config.vagrant.validate. If any errors are collected under the 'vagrant' key, they are rendered through the config/validation_failed template and raised as Vagrant::Errors::ConfigInvalid with the rendered list in %{errors}. This guards the local-plugins flow before anything is installed.

Source

Thrown at plugins/commands/plugin/command/install.rb:43

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

            o.on("--verbose", "Enable verbose output for plugin installation") do |v|
              options[:verbose] = v
            end
          end

          # Parse the options
          argv = parse_options(opts)
          return if !argv

          if argv.length < 1
            raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if !options[:env_local]

            errors = @env.vagrantfile.config.vagrant.validate(nil)
            if !errors["vagrant"].empty?
              raise Errors::ConfigInvalid,
                errors: Util::TemplateRenderer.render(
                "config/validation_failed",
                errors: errors)
            end

            local_plugins = @env.vagrantfile.config.vagrant.plugins
            plugin_list = local_plugins.map do |name, info|
              "#{name} (#{info.fetch(:version, "> 0")})"
            end.join("\n")


            @env.ui.info(I18n.t("vagrant.plugins.local.install_all",
              plugins: plugin_list) + "\n")

            # Pause to allow user to cancel
            sleep(LOCAL_INSTALL_PAUSE)

            local_plugins.each do |name, info|

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Read the rendered error list in the message — each line names the invalid setting.
  2. Fix the offending `config.vagrant.plugins` / vagrant-section entries (use a Hash of name => options or an Array of names).
  3. Re-validate with `vagrant validate`, then re-run `vagrant plugin install --local`.

Example fix

# before (Vagrantfile)
config.vagrant.plugins = 42
# after
config.vagrant.plugins = { "vagrant-aws" => { version: ">= 1.0.0" } }
Defensive patterns

Strategy: validation

Validate before calling

# Validate before the local-plugin install
system('vagrant', 'validate') or abort 'Vagrantfile has config errors; fix them first'
system('vagrant', 'plugin', 'install', '--local')

Try / catch

begin
  Vagrant::Environment.new.cli(['plugin', 'install', '--local'])
rescue Vagrant::Errors::ConfigInvalid => e
  warn e.message # rendered list of invalid settings
  exit 1
end

Prevention

When it happens

Trigger: A Vagrantfile whose `config.vagrant` section is invalid — e.g. `config.vagrant.plugins` assigned a non-Hash/non-Array value, malformed version constraints, or unknown keys in plugin entries — then running `vagrant plugin install --local` with no names.

Common situations: Hand-editing the plugins block and breaking syntax; upgrading Vagrant where the vagrant config section gained stricter validation; merging Vagrantfiles and clobbering the plugins entry with a scalar.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


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