{"record":{"id":"7cd615048cb7f6fc","repo":"hashicorp/vagrant","slug":"there-was-an-error-loading-a-vagrantfile-the-file-7cd615","errorCode":null,"errorMessage":"There was an error loading a Vagrantfile. The file being loaded\nand the error message are shown below. This is usually caused by\na syntax error.\n\nPath: %{path}\nLine number: %{line}\nMessage: %{exception_class}: %{message}","messagePattern":"There was an error loading a Vagrantfile\\. The file being loaded\nand the error message are shown below\\. This is usually caused by\na syntax error\\.\n\nPath: %(.+?)\nLine number: %(.+?)\nMessage: %(.+?): %(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::VagrantfileLoadError","httpStatus":null,"severity":"error","filePath":"plugins/kernel_v2/config/vm.rb","lineNumber":651,"sourceCode":"\n          begin\n            blocks.each do |b|\n              new_config = config_class.new\n              b.call(new_config, Vagrant::Config::V2::DummyConfig.new)\n              config = config.merge(new_config)\n            end\n          rescue Exception => e\n            @logger.error(\"Vagrantfile load error: #{e.message}\")\n            @logger.error(e.inspect)\n            @logger.error(e.message)\n            @logger.error(e.backtrace.join(\"\\n\"))\n\n            line = \"(unknown)\"\n            if e.backtrace && e.backtrace[0]\n              line = e.backtrace.first.slice(0, e.backtrace.first.rindex(':')).rpartition(':').last\n            end\n\n            raise Vagrant::Errors::VagrantfileLoadError,\n              path: \"<provider config: #{name}>\",\n              line: line,\n              exception_class: e.class,\n              message: e.message\n          end\n\n          config.finalize!\n\n          # Store it for retrieval later\n          @__compiled_provider_configs[name]   = config\n        end\n\n        # Finalize all the provisioners\n        @provisioners.each do |p|\n          p.config.finalize! if !p.invalid?\n          p.run = p.run.to_sym if p.run\n        end\n","sourceCodeStart":633,"sourceCodeEnd":669,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/kernel_v2/config/vm.rb#L633-L669","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nconfig.vm.provider \"docker\" do |d|\n  d.image = \"ubuntu:22.04\"\n  d.build_arg = \"/srv\" # not a real option -> NoMethodError inside provider block\nend\n\n# after\nconfig.vm.provider \"docker\" do |d|\n  d.image = \"ubuntu:22.04\"\n  d.build_args = [\"/srv\"]\nend","handlingStrategy":"validation","validationCode":"# syntax + load check before running real commands\nruby -c Vagrantfile && vagrant validate","typeGuard":null,"tryCatchPattern":"begin\n  Vagrant::Environment.new(cwd: project_dir).cli(\"status\")\nrescue Vagrant::Errors::VagrantfileLoadError => e\n  # path prefix '<provider config: name>' identifies which provider block failed\n  abort \"Provider config block failed: #{e.message}\"\nend","preventionTips":["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"],"tags":["vagrant","vagrantfile","provider-config","config","ruby"],"backgroundTag":"config-block-eval-error","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}