hashicorp/vagrant · error · Vagrant::Errors::HomeDirectoryNotAccessible

The home directory you specified is not accessible. The home

Error message

The home directory you specified is not accessible. The home
directory that Vagrant uses must be both readable and writable.

You specified: %{home_path}

What it means

Raised as Vagrant::Errors::HomeDirectoryNotAccessible from home-directory setup (lib/vagrant/environment.rb:866) when FileUtils.mkdir_p on a required directory under the Vagrant home (~/.vagrant.d or $VAGRANT_HOME — the subdirectories include tmp and the machine index dir) raises Errno::EACCES or Errno::EROFS. It aborts environment creation before Vagrant can do anything else.

Source

Thrown at lib/vagrant/environment.rb:866

      dirs    = [
        @home_path,
        @home_path.join("rgloader"),
        @boxes_path,
        @data_dir,
        @gems_path,
        @tmp_path,
        @machine_index_dir,
      ]

      # Go through each required directory, creating it if it doesn't exist
      dirs.each do |dir|
        next if File.directory?(dir)

        begin
          @logger.info("Creating: #{dir}")
          FileUtils.mkdir_p(dir)
        rescue Errno::EACCES, Errno::EROFS
          raise Errors::HomeDirectoryNotAccessible, home_path: @home_path.to_s
        end
      end

      # Attempt to write into the home directory to verify we can
      begin
        # Append a random suffix to avoid race conditions if Vagrant
        # is running in parallel with other Vagrant processes.
        suffix = (0...32).map { (65 + rand(26)).chr }.join
        path   = @home_path.join("perm_test_#{suffix}")
        path.open("w") do |f|
          f.write("hello")
        end
        path.unlink
      rescue Errno::EACCES
        raise Errors::HomeDirectoryNotAccessible, home_path: @home_path.to_s
      end

      # Create the version file that we use to track the structure of

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Inspect ownership: `ls -ld ~/.vagrant.d` (and `echo $VAGRANT_HOME`), then take it back: `sudo chown -R $(id -u):$(id -g) ~/.vagrant.d`
  2. If VAGRANT_HOME points somewhere unwritable, point it at a writable directory or unset it
  3. On a read-only root filesystem, give Vagrant a writable home: `export VAGRANT_HOME=/tmp/vagrant.d`
  4. Stop running vagrant under sudo, or keep home ownership consistent when root is unavoidable

Example fix

# before
$ sudo vagrant up        # creates root-owned ~/.vagrant.d subdirs
$ vagrant status          # HomeDirectoryNotAccessible

# after
$ sudo chown -R $(id -u):$(id -g) ~/.vagrant.d
$ vagrant status
Defensive patterns

Strategy: validation

Validate before calling

home = ENV["VAGRANT_HOME"] || File.expand_path("~/.vagrant.d")
writable = File.writable?(home) rescue false
writable ||= !File.exist?(home) && File.writable?(File.dirname(home))
raise ArgumentError, "vagrant home #{home} is not writable" unless writable

Try / catch

begin
  env = Vagrant::Environment.new
rescue Vagrant::Errors::HomeDirectoryNotAccessible => e
  abort "Fix permissions on #{e.extra_data[:home_path]} (chown/chmod) or set VAGRANT_HOME"
end

Prevention

When it happens

Trigger: The home directory path exists but is owned by another user (classic after one `sudo vagrant` run creates root-owned dirs under ~/.vagrant.d), sits on a read-only filesystem (EROFS in containers/appliances), or $VAGRANT_HOME points at an unwritable location.

Common situations: Alternating sudo and normal-user vagrant invocations; CI containers with read-only $HOME; VAGRANT_HOME redirected to a root-created or NFS-root-squashed path.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/de1e63628840d46c. Report an issue: GitHub.