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
During config finalization Vagrant evaluates each provider-specific block (config.vm.provider "name" do |vm| ...). VMConfig#__compile_provider_configs rescues any exception raised inside such a block and re-raises VagrantfileLoadError with path '<provider config: name>', the backtrace line number, and the original class/message - the wrapped exception is the real problem.
Source
Thrown at plugins/kernel_v2/config/vm.rb:651
begin
blocks.each do |b|
new_config = config_class.new
b.call(new_config, Vagrant::Config::V2::DummyConfig.new)
config = config.merge(new_config)
end
rescue Exception => e
@logger.error("Vagrantfile load error: #{e.message}")
@logger.error(e.inspect)
@logger.error(e.message)
@logger.error(e.backtrace.join("\n"))
line = "(unknown)"
if e.backtrace && e.backtrace[0]
line = e.backtrace.first.slice(0, e.backtrace.first.rindex(':')).rpartition(':').last
end
raise Vagrant::Errors::VagrantfileLoadError,
path: "<provider config: #{name}>",
line: line,
exception_class: e.class,
message: e.message
end
config.finalize!
# Store it for retrieval later
@__compiled_provider_configs[name] = config
end
# Finalize all the provisioners
@provisioners.each do |p|
p.config.finalize! if !p.invalid?
p.run = p.run.to_sym if p.run
end
View on GitHub (pinned to 35f3160f4a)
Solutions
- Read the Message: line - the wrapped exception class and text identify the failing call in the provider block
- Fix or remove the failing statement inside the config.vm.provider block
- Verify the provider plugin version matches the options used (`vagrant plugin list`, `vagrant -v`) and check the changelog for renamed options
- Re-run `vagrant validate` after the fix
Example fix
# before config.vm.provider "docker" do |d| d.image = "ubuntu:22.04" d.build_arg = "/srv" # not a real option -> NoMethodError inside provider block end # after config.vm.provider "docker" do |d| d.image = "ubuntu:22.04" d.build_args = ["/srv"] end
Defensive patterns
Strategy: validation
Validate before calling
# syntax + load check before running real commands ruby -c Vagrantfile && vagrant validate
Try / catch
begin
Vagrant::Environment.new(cwd: project_dir).cli("status")
rescue Vagrant::Errors::VagrantfileLoadError => e
# path prefix '<provider config: name>' identifies which provider block failed
abort "Provider config block failed: #{e.message}"
end Prevention
- Pin Vagrant and provider plugin versions so option names stay valid
- Re-run `vagrant validate` after upgrades
- Copy provider option names from the docs of the version you run, not master
When it happens
Trigger: A config.vm.provider block that calls an undefined setter or method (NoMethodError), passes a malformed value (ArgumentError, IPAddr errors), or uses provider config API removed or renamed in the installed Vagrant version.
Common situations: Provider options that exist only in other versions (docker/hyperv/virtualbox option names changed across releases); typos in option names; referencing nil data inside the block.
Related errors
- There was an error loading a Vagrantfile. The file being loa
- There was an error loading a Vagrantfile. The file being loa
- There is a syntax error in the following Vagrantfile. The sy
- There was an error parsing the Vagrantfile: No config was gi
- There are errors in the configuration of this machine. Pleas
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/7cd615048cb7f6fc.
Report an issue: GitHub.