{"record":{"id":"79c017587a5d51fe","repo":"hashicorp/vagrant","slug":"there-was-an-error-loading-a-vagrantfile-the-file-79c017","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/push.rb","lineNumber":57,"sourceCode":"          begin\n            tuples.each do |s, b|\n              # Update the strategy if it has changed, resetting the current\n              # config object.\n              if s != strategy\n                @logger.warn(\"duplicate strategy defined, overwriting config\")\n                strategy = s\n                config = config_class.new\n              end\n\n              # If we don't have any blocks, then ignore it\n              next if b.nil?\n\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            raise Vagrant::Errors::VagrantfileLoadError,\n              path: \"<push config: #{name}>\",\n              message: e.message\n          end\n\n          config.finalize!\n          # It's important that we call _finalize! here also, because pushes get\n          # plucked out of the config in Environment#push without the larger\n          # root.finalize! walk having been done. This means that push configs\n          # were coming out unfinalized, which can cause havoc when they're\n          # passed through functions that attempt to capture keyword arguments,\n          # as they'll cause ruby to call .to_hash on the config, get a\n          # DummyConfig, and then blow up. That havoc was happening in server\n          # mode, and this call fixes it.\n          config._finalize!\n\n          # Store it for retrieval later\n          @__compiled_pushes[name] = [strategy, config]\n        end","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/kernel_v2/config/push.rb#L39-L75","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the Message: line of the error - it contains the original exception class and text pointing at the failing line inside the push block","Fix or remove the failing call inside the config.push.define block in the Vagrantfile","Check `vagrant plugin list` and install/upgrade the push strategy plugin whose options you are configuring","Re-check with `vagrant validate` or `vagrant status` after the fix"],"exampleFix":"# before\nconfig.push.define \"ftp\" do |p|\n  p.hostt = \"files.example.com\" # typo -> NoMethodError inside push block\nend\n\n# after\nconfig.push.define \"ftp\" do |p|\n  p.host = \"files.example.com\"\nend","handlingStrategy":"validation","validationCode":"# syntax + load check before running real commands\nruby -c Vagrantfile && vagrant validate","typeGuard":null,"tryCatchPattern":"begin\n  env = Vagrant::Environment.new(cwd: project_dir)\n  env.cli(\"status\")\nrescue Vagrant::Errors::VagrantfileLoadError => e\n  # e.message embeds the wrapped exception; surface it, do not retry blindly\n  abort \"Vagrantfile load failed: #{e.message}\"\nend","preventionTips":["Run `vagrant validate` in CI on every Vagrantfile change","Keep push blocks limited to options documented for the installed strategy plugin","Re-run `vagrant status` after upgrading push plugins, since config classes change between versions"],"tags":["vagrant","vagrantfile","push","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"}