{"record":{"id":"4ab550313b794ce3","repo":"hashicorp/vagrant","slug":"failed-to-parse-the-state-file-path-messag","errorCode":null,"errorMessage":"Failed to parse the state file \"%{path}\":\n%{message}\n\nPlease remove the file and reinstall the plugins.\nIf this error recurs, please report a bug.","messagePattern":"Failed to parse the state file \"%(.+?)\":\n%(.+?)\n\nPlease remove the file and reinstall the plugins\\.\nIf this error recurs, please report a bug\\.","errorType":"exception","errorClass":"Vagrant::Errors::PluginStateFileParseError","httpStatus":null,"severity":"error","filePath":"lib/vagrant/plugin/state_file.rb","lineNumber":25,"sourceCode":"\nmodule Vagrant\n  module Plugin\n    # This is a helper to deal with the plugin state file that Vagrant\n    # uses to track what plugins are installed and activated and such.\n    class StateFile\n\n      # @return [Pathname] path to file\n      attr_reader :path\n\n      def initialize(path)\n        @path = path\n\n        @data = {}\n        if @path.exist?\n          begin\n            @data = JSON.parse(@path.read)\n          rescue JSON::ParserError => e\n            raise Vagrant::Errors::PluginStateFileParseError,\n              path: path, message: e.message\n          end\n\n          upgrade_v0! if !@data[\"version\"]\n        end\n\n        @data[\"version\"] ||= \"1\"\n        @data[\"installed\"] ||= {}\n      end\n\n      # Add a plugin that is installed to the state file.\n      #\n      # @param [String] name The name of the plugin\n      def add_plugin(name, **opts)\n        @data[\"installed\"][name] = {\n          \"ruby_version\"          => RUBY_VERSION,\n          \"vagrant_version\"       => Vagrant::VERSION,\n          \"gem_version\"           => opts[:version] || \"\",","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/lib/vagrant/plugin/state_file.rb#L7-L43","documentation":"Vagrant::Plugin::StateFile reads the plugins state file (~/.vagrant.d/plugins.json, or a project-local .vagrant/plugins.json) and raises PluginStateFileParseError in initialize when the file exists but JSON.parse fails (lib/vagrant/plugin/state_file.rb:25). The file records which plugins are installed, so any truncation, stray comma, or non-JSON content breaks every plugin operation. As the message states, recovery is to remove the file and reinstall the plugins.","triggerScenarios":"Constructing StateFile.new(path) — which Vagrant does at startup for every plugin command — when the JSON at path is invalid: a write interrupted by killing the process mid `vagrant plugin install`, a hand edit that broke syntax, or a sync/merge tool writing conflict markers into the file.","commonSituations":"Syncing ~/.vagrant.d with cloud-sync tools that generate conflict files; CI images built by copying a half-written plugins.json; Windows editors adding a BOM or CRLF; two Vagrant versions writing the file concurrently.","solutions":["Validate the file to find the syntax error: `jq . ~/.vagrant.d/plugins.json` or `python -m json.tool` — fix the flagged spot or restore from backup","Otherwise follow the message: rename/remove the file and reinstall the plugin set (capture `vagrant plugin list` first if it still runs, or replay your setup script)","Simply deleting the file is safe — Vagrant regenerates an empty state file on the next plugin install","Prevent recurrence: stop syncing VAGRANT_HOME during operations and never kill vagrant mid plugin command"],"exampleFix":"// before (~/.vagrant.d/plugins.json — broken JSON)\n{\"version\": \"1\", \"installed\": {\"vagrant-vbguest\": {\"ruby_version\": \"2.6.6\",},}}\n\n// after (valid)\n{\"version\": \"1\", \"installed\": {\"vagrant-vbguest\": {\"ruby_version\": \"2.6.6\", \"version\": \"0.30.0\"}}}","handlingStrategy":"validation","validationCode":"path = File.expand_path(\"~/.vagrant.d/plugins.json\")\nif File.exist?(path)\n  begin\n    JSON.parse(File.read(path))\n  rescue JSON::ParserError => e\n    abort \"plugins.json is corrupt (#{e.message}); restore it before running vagrant\"\n  end\nend","typeGuard":null,"tryCatchPattern":"begin\n  state_file = Vagrant::Plugin::StateFile.new(path)\nrescue Vagrant::Errors::PluginStateFileParseError => e\n  d = e.extra_data # {path:, message:}\n  warn \"corrupt state file #{d[:path]}: #{d[:message]}\"\nend","preventionTips":["Back up plugins.json before hand-editing it","Never terminate vagrant during plugin install/uninstall","Exclude VAGRANT_HOME from naive file-sync and merge tools","Validate the file with `jq` after any manual modification"],"tags":["plugins","json","state-file","corruption"],"backgroundTag":"corrupted-json-file","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}