{"record":{"id":"fa278a867e674635","repo":"hashicorp/vagrant","slug":"the-directory-vagrant-will-use-to-store-local-envi","errorCode":null,"errorMessage":"The directory Vagrant will use to store local environment-specific\nstate is not accessible. The directory specified as the local data\ndirectory must be both readable and writable for the user that is\nrunning Vagrant.\n\nLocal data directory: %{local_data_path}","messagePattern":"The directory Vagrant will use to store local environment-specific\nstate is not accessible\\. The directory specified as the local data\ndirectory must be both readable and writable for the user that is\nrunning Vagrant\\.\n\nLocal data directory: %(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::LocalDataDirectoryNotAccessible","httpStatus":null,"severity":"error","filePath":"lib/vagrant/environment.rb","lineNumber":957,"sourceCode":"      if @local_data_path.file?\n        upgrade_v1_dotfile(@local_data_path)\n      end\n\n      # If we don't have a root path, we don't setup anything\n      return if !force && root_path.nil?\n\n      begin\n        @logger.debug(\"Creating: #{@local_data_path}\")\n        FileUtils.mkdir_p(@local_data_path)\n        # Create the rgloader/loader file so we can use encoded files.\n        loader_file = @local_data_path.join(\"rgloader\", \"loader.rb\")\n        if !loader_file.file?\n          source_loader = Vagrant.source_root.join(\"templates/rgloader.rb\")\n          FileUtils.mkdir_p(@local_data_path.join(\"rgloader\").to_s)\n          FileUtils.cp(source_loader.to_s, loader_file.to_s)\n        end\n      rescue Errno::EACCES\n        raise Errors::LocalDataDirectoryNotAccessible,\n          local_data_path: @local_data_path.to_s\n      end\n    end\n\n    protected\n\n    # Attempt to guess the configured provider in use. Will fallback\n    # to the default provider if an explicit provider name is not\n    # provided. This can be pretty error prone, but is used during\n    # initial environment setup to allow loading plugins so it doesn't\n    # need to be perfect\n    #\n    # @return [String]\n    def guess_provider\n      gp = nil\n      ARGV.each_with_index do |val, idx|\n        if val.start_with?(\"--provider=\")\n          gp = val.split(\"=\", 2).last","sourceCodeStart":939,"sourceCodeEnd":975,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/lib/vagrant/environment.rb#L939-L975","documentation":"Raised as Vagrant::Errors::LocalDataDirectoryNotAccessible from setup_local_data_path (lib/vagrant/environment.rb:957) when FileUtils.mkdir_p(@local_data_path) — the project's .vagrant/ directory (or VAGRANT_DOTFILE_PATH target) — or the rgloader loader.rb copy into it raises Errno::EACCES.","triggerScenarios":"The project directory or an existing .vagrant directory is owned by root because a previous `sudo vagrant` ran there; the project lives under a root-owned checkout (e.g. /opt) or on a read-only mount, so the current user cannot create/write .vagrant.","commonSituations":"Mixed sudo/non-sudo usage in one project (root-owned .vagrant); repositories cloned into system paths; NFS/SMB mounts with permission mismatches between guest and host users.","solutions":["Inspect `ls -ld . .vagrant` — if .vagrant is root-owned and its state is expendable, `sudo rm -rf .vagrant` and let Vagrant recreate it (machines re-sync on next `vagrant up`)","Otherwise fix ownership: `sudo chown -R $(id -u):$(id -g) .vagrant`","Ensure the parent project directory itself is writable by your user, and relocate projects out of root-owned paths","Never alternate sudo and non-sudo vagrant in the same project directory"],"exampleFix":"# before\n$ ls -ld .vagrant\ndrwxr-xr-x 1 root root ... .vagrant\n$ vagrant up   # LocalDataDirectoryNotAccessible\n\n# after\n$ sudo chown -R $(id -u):$(id -g) .vagrant\n$ vagrant up","handlingStrategy":"validation","validationCode":"local = ENV[\"VAGRANT_DOTFILE_PATH\"] || File.join(Dir.pwd, \".vagrant\")\nparent = File.dirname(local)\nraise ArgumentError, \"cannot create local data dir #{local}\" unless File.writable?(parent)\nraise ArgumentError, \"local data dir #{local} not writable\" if File.exist?(local) && !File.writable?(local)","typeGuard":null,"tryCatchPattern":"begin\n  env = Vagrant::Environment.new(cwd: project_dir)\nrescue Vagrant::Errors::LocalDataDirectoryNotAccessible => e\n  abort \"Fix ownership of #{e.extra_data[:local_data_path]} (chown to $(id -u)) or its parent\"\nend","preventionTips":["Run vagrant as the user that owns the project checkout, never sudo for convenience","Keep projects in user-owned directories, not /opt or system paths","If sudo was used, chown -R the project's .vagrant back before the next normal run"],"tags":["vagrant","local-data","permissions","project-directory","eacces"],"backgroundTag":"permission-denied","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}