{"record":{"id":"aa84175dbcf1d1a0","repo":"hashicorp/vagrant","slug":"there-is-a-syntax-error-in-the-following-vagrantfi","errorCode":null,"errorMessage":"There is a syntax error in the following Vagrantfile. The syntax error message is reproduced below for convenience:\n\n%{file}","messagePattern":"There is a syntax error in the following Vagrantfile\\. The syntax error message is reproduced below for convenience:\n\n%(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::VagrantfileSyntaxError","httpStatus":null,"severity":"error","filePath":"lib/vagrant/config/loader.rb","lineNumber":290,"sourceCode":"        else\n          raise ArgumentError, \"Unknown configuration source: #{reliably_inspected_sources[source]}\"\n        end\n      end\n\n      # This returns an array of `Proc` objects for the given path source.\n      #\n      # @param [String] path Path to the file which contains the proper\n      #   `Vagrant.configure` calls.\n      # @return [Array<Proc>]\n      def procs_for_path(path)\n        @logger.debug(\"Load procs for pathname: #{path}\")\n\n        return Config.capture_configures do\n          begin\n            Kernel.load path\n          rescue SyntaxError => e\n            # Report syntax errors in a nice way.\n            raise Errors::VagrantfileSyntaxError, file: e.message\n          rescue SystemExit\n            # Continue raising that exception...\n            raise\n          rescue Vagrant::Errors::VagrantError\n            # Continue raising known Vagrant errors since they already\n            # contain well worded error messages and context.\n            raise\n          rescue Exception => e\n            @logger.error(\"Vagrantfile load error: #{e.message}\")\n            @logger.error(e.backtrace.join(\"\\n\"))\n\n            line = \"(unknown)\"\n            if e.backtrace && e.backtrace[0]\n              e.backtrace[0].split(\":\").each do |part|\n                if part =~ /\\d+/\n                  line = part.to_i\n                  break\n                end","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/lib/vagrant/config/loader.rb#L272-L308","documentation":"Raised as Vagrant::Errors::VagrantfileSyntaxError from Config::Loader#procs_for_path (lib/vagrant/config/loader.rb:290) when Kernel.load(path) on the Vagrantfile raises SyntaxError — the file is not parseable Ruby. The raw Ruby parser message (which includes the file, line, and offending token) is passed through verbatim in the `file` placeholder, so users see Ruby's own diagnostic.","triggerScenarios":"Any vagrant command in a project whose Vagrantfile (or the file being loaded as it) fails to parse: unbalanced end/do, unmatched quote, stray character, malformed heredoc, or a missing `do` keyword. The exception happens during Kernel.load before any config block is captured or evaluated.","commonSituations":"Hand-editing a Vagrantfile and dropping an `end`; git merges that break block structure; template/ERB generators emitting invalid Ruby; Windows line endings or smart quotes pasted from blog posts.","solutions":["Run `ruby -c Vagrantfile` to get the exact parser error and line number","Fix the reported line — usually a missing or extra `end`, `do`, quote, or comma","If the file is generated, fix the template/generator and regenerate rather than hand-patching","Re-run `vagrant validate` to confirm the file parses before running real commands"],"exampleFix":"# before\nVagrant.configure(\"2\") do |config|\n  config.vm.box = \"ubuntu/jammy64\"\n# missing `end` for the configure block\n\n# after\nVagrant.configure(\"2\") do |config|\n  config.vm.box = \"ubuntu/jammy64\"\nend","handlingStrategy":"validation","validationCode":"# Parse-check before any vagrant automation\nout = `ruby -c Vagrantfile 2>&1`\nabort \"Vagrantfile syntax error:\\n#{out}\" unless $?.success? && out.include?(\"Syntax OK\")","typeGuard":null,"tryCatchPattern":"begin\n  Vagrant::Environment.new(cwd: dir).vagrantfile\nrescue Vagrant::Errors::VagrantfileSyntaxError => e\n  abort \"Fix Vagrantfile syntax: #{e.extra_data[:file]}\"\nend","preventionTips":["Run `ruby -c Vagrantfile` after every manual edit","Edit Vagrantfiles with a Ruby-aware editor so block structure is highlighted","Keep generated Vagrantfiles under template tests so bad interpolation never reaches users"],"tags":["vagrant","vagrantfile","syntax-error","ruby","parse-error"],"backgroundTag":"config-file-syntax-error","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}