{"record":{"id":"ec6ff1070ab14d7e","repo":"hashicorp/vagrant","slug":"failed-to-create-the-following-shared-folder-on-th","errorCode":null,"errorMessage":"Failed to create the following shared folder on the host system. This is usually because Vagrant does not have sufficient permissions to create the folder.\n\n%{path}\n\nPlease create the folder manually or specify another path to share.","messagePattern":"Failed to create the following shared folder on the host system\\. This is usually because Vagrant does not have sufficient permissions to create the folder\\.\n\n%(.+?)\n\nPlease create the folder manually or specify another path to share\\.","errorType":"exception","errorClass":"Vagrant::Errors::SharedFolderCreateFailed","httpStatus":null,"severity":"error","filePath":"lib/vagrant/action/builtin/synced_folders.rb","lineNumber":62,"sourceCode":"          folders.each do |_, fs|\n            fs.each do |id, data|\n              next if data[:hostpath_exact]\n\n              data[:hostpath] = File.expand_path(\n                data[:hostpath], env[:root_path])\n\n              # Expand the symlink if this is a path that exists\n              if File.file?(data[:hostpath])\n                data[:hostpath] = File.realpath(data[:hostpath])\n              end\n\n              # Create the hostpath if it doesn't exist and we've been told to\n              if !File.directory?(data[:hostpath]) && data[:create]\n                @logger.info(\"Creating shared folder host directory: #{data[:hostpath]}\")\n                begin\n                  Pathname.new(data[:hostpath]).mkpath\n                rescue Errno::EACCES\n                  raise Vagrant::Errors::SharedFolderCreateFailed,\n                    path: data[:hostpath]\n                end\n              end\n\n              if File.directory?(data[:hostpath])\n                data[:hostpath] = File.realpath(data[:hostpath])\n                data[:hostpath] = Util::Platform.fs_real_path(data[:hostpath]).to_s\n              end\n            end\n          end\n\n          # Build up the instances of the synced folders. We do this once\n          # so that they can store state.\n          folders = folders.map do |impl_name, fs|\n            instance = plugins[impl_name.to_sym][0].new\n            [instance, impl_name, fs]\n          end\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/lib/vagrant/action/builtin/synced_folders.rb#L44-L80","documentation":"In the synced_folders setup step, hostpaths marked `create: true` that do not exist are made with Pathname#mkpath. If the host OS raises Errno::EACCES — the vagrant process lacks permission to create directories under the parent — the error is converted to SharedFolderCreateFailed naming the path.","triggerScenarios":"`config.vm.synced_folder \"PATH\", \"/guest\", create: true` where PATH's parent is not writable by the current user: paths under /srv, /opt, another user's home, or on a read-only mount (lib/vagrant/action/builtin/synced_folders.rb:54-66).","commonSituations":"Sharing system directories on locked-down/corporate hosts; running vagrant as an unprivileged user against root-owned trees; read-only or network mounts used as the synced-folder root; SELinux/AppArmor denying writes.","solutions":["Pre-create the directory yourself with proper ownership: `sudo mkdir -p /srv/data && sudo chown $USER /srv/data`, then drop `create: true` (or keep it).","Or move the hostpath somewhere you own, e.g. `~/vagrant-data`.","Or run vagrant from an account with write access to the target parent directory."],"exampleFix":"# before\nconfig.vm.synced_folder \"/srv/shared-data\", \"/data\", create: true\n# => SharedFolderCreateFailed (EACCES under /srv)\n\n# after: pre-create + own the dir\n#   sudo mkdir -p /srv/shared-data && sudo chown \"$USER\" /srv/shared-data\nconfig.vm.synced_folder \"/srv/shared-data\", \"/data\"\n# or simply:\nconfig.vm.synced_folder \"~/vagrant-data\", \"/data\", create: true","handlingStrategy":"validation","validationCode":"# Ruby: check you can create the hostpath before vagrant does\nrequire \"fileutils\"\nhostpath = File.expand_path(\"/srv/shared-data\")\nbegin\n  FileUtils.mkdir_p(hostpath) unless Dir.exist?(hostpath)\nrescue Errno::EACCES\n  abort \"no permission to create #{hostpath}; sudo mkdir/chown it first\"\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-create synced-folder host directories in your bootstrap with correct ownership instead of relying on create: true.","Keep hostpaths inside user-owned locations (~/projects/...) or pre-chowned system dirs.","Watch for read-only/network mounts when choosing hostpath roots."],"tags":["vagrant","synced-folders","permissions","filesystem"],"backgroundTag":"permission-denied","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}