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

There was an error loading a Vagrantfile. The file being loa

Error message

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: %{path}
Line number: %{line}
Message: %{exception_class}: %{message}

What it means

Vagrant wraps any exception raised while evaluating a push strategy block in the Vagrantfile (config.push.define / push) into VagrantfileLoadError during config finalization. PushConfig#finalize! replays each stored block against the strategy's config class (a DummyConfig when no plugin registered one), so a NoMethodError, ArgumentError or any other error inside the block is re-raised with path '<push config: name>' and the original message. The real cause is the wrapped exception, not the load machinery.

Source

Thrown at plugins/kernel_v2/config/push.rb:57

          begin
            tuples.each do |s, b|
              # Update the strategy if it has changed, resetting the current
              # config object.
              if s != strategy
                @logger.warn("duplicate strategy defined, overwriting config")
                strategy = s
                config = config_class.new
              end

              # If we don't have any blocks, then ignore it
              next if b.nil?

              new_config = config_class.new
              b.call(new_config, Vagrant::Config::V2::DummyConfig.new)
              config = config.merge(new_config)
            end
          rescue Exception => e
            raise Vagrant::Errors::VagrantfileLoadError,
              path: "<push config: #{name}>",
              message: e.message
          end

          config.finalize!
          # It's important that we call _finalize! here also, because pushes get
          # plucked out of the config in Environment#push without the larger
          # root.finalize! walk having been done. This means that push configs
          # were coming out unfinalized, which can cause havoc when they're
          # passed through functions that attempt to capture keyword arguments,
          # as they'll cause ruby to call .to_hash on the config, get a
          # DummyConfig, and then blow up. That havoc was happening in server
          # mode, and this call fixes it.
          config._finalize!

          # Store it for retrieval later
          @__compiled_pushes[name] = [strategy, config]
        end

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Read the Message: line of the error - it contains the original exception class and text pointing at the failing line inside the push block
  2. Fix or remove the failing call inside the config.push.define block in the Vagrantfile
  3. Check `vagrant plugin list` and install/upgrade the push strategy plugin whose options you are configuring
  4. Re-check with `vagrant validate` or `vagrant status` after the fix

Example fix

# before
config.push.define "ftp" do |p|
  p.hostt = "files.example.com" # typo -> NoMethodError inside push block
end

# after
config.push.define "ftp" do |p|
  p.host = "files.example.com"
end
Defensive patterns

Strategy: validation

Validate before calling

# syntax + load check before running real commands
ruby -c Vagrantfile && vagrant validate

Try / catch

begin
  env = Vagrant::Environment.new(cwd: project_dir)
  env.cli("status")
rescue Vagrant::Errors::VagrantfileLoadError => e
  # e.message embeds the wrapped exception; surface it, do not retry blindly
  abort "Vagrantfile load failed: #{e.message}"
end

Prevention

When it happens

Trigger: Declaring config.push.define("name") { |s| ... } whose block raises: a typo'd setter on a strict strategy config class (NoMethodError), an invalid option value, or a NameError from referencing undefined helpers. Note that if the strategy plugin is absent the block runs against DummyConfig and passes silently, so this error specifically means the block itself raised.

Common situations: Typos in push option names; push blocks copied from a different plugin version whose config class changed; blocks that reference variables which are nil at finalization time.

Related errors


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