{"record":{"id":"38864d81361a1f2c","repo":"hashicorp/vagrant","slug":"vagrant-failed-to-install-an-updated-nfs-exports-f","errorCode":null,"errorMessage":"Vagrant failed to install an updated NFS exports file. This may be\ndue to overly restrictive permissions on your NFS exports file. Please\nvalidate them and try again.\n\ncommand: %{command}\nstdout: %{stdout}\nstderr: %{stderr}","messagePattern":"Vagrant failed to install an updated NFS exports file\\. This may be\ndue to overly restrictive permissions on your NFS exports file\\. Please\nvalidate them and try again\\.\n\ncommand: %(.+?)\nstdout: %(.+?)\nstderr: %(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::NFSExportsFailed","httpStatus":null,"severity":"error","filePath":"plugins/hosts/linux/cap/nfs.rb","lineNumber":199,"sourceCode":"\n              # Write contents out to temporary file\n              new_exports_path = File.join(Dir.tmpdir, \"vagrant-exports\")\n              FileUtils.rm_f(new_exports_path)\n              new_exports_file = File.open(new_exports_path, \"w+\")\n              new_exports_file.puts(new_exports_content)\n              new_exports_file.close\n\n              # Ensure new file mode and uid/gid match existing file to replace\n              existing_stat = File.stat(NFS_EXPORTS_PATH)\n              new_stat = File.stat(new_exports_path)\n              if existing_stat.mode != new_stat.mode\n                File.chmod(existing_stat.mode, new_exports_path)\n              end\n              if existing_stat.uid != new_stat.uid || existing_stat.gid != new_stat.gid\n                chown_cmd = \"sudo chown #{existing_stat.uid}:#{existing_stat.gid} #{new_exports_path}\"\n                result = Vagrant::Util::Subprocess.execute(*Shellwords.split(chown_cmd))\n                if result.exit_code != 0\n                  raise Vagrant::Errors::NFSExportsFailed,\n                    command: chown_cmd,\n                    stderr: result.stderr,\n                    stdout: result.stdout\n                end\n              end\n              # Always force move the file to prevent overwrite prompting\n              sudo_command = \"sudo \" if !exports_path.writable? || !exports_path.dirname.writable?\n              mv_cmd = \"#{sudo_command}mv -f #{new_exports_path} #{NFS_EXPORTS_PATH}\"\n              result = Vagrant::Util::Subprocess.execute(*Shellwords.split(mv_cmd))\n              if result.exit_code != 0\n                raise Vagrant::Errors::NFSExportsFailed,\n                  command: mv_cmd,\n                  stderr: result.stderr,\n                  stdout: result.stdout\n              end\n            ensure\n              if !new_exports_path.nil? && File.exist?(new_exports_path)\n                File.unlink(new_exports_path)","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/hosts/linux/cap/nfs.rb#L181-L217","documentation":"Vagrant::Errors::NFSExportsFailed raised at plugins/hosts/linux/cap/nfs.rb:199 while installing the regenerated exports file. Vagrant writes a new temp /etc/exports preserving the existing file's mode and owner; when uid/gid differ it runs `sudo chown <uid>:<gid> <tmpfile>` via Subprocess, and a non-zero exit raises with that exact command plus stdout/stderr.","triggerScenarios":"On a Linux host, an NFS-synced-folder up/reload stages the temp exports file and the sudo chown fails: sudo needs a password but there is no TTY, sudoers denies the command for this user, or the temp file disappeared (race/cleanup).","commonSituations":"CI runners or cron/daemon contexts without passwordless sudo; NOPASSWD entries that don't cover chown/mv; strict corporate sudoers policies; /etc on an unusual filesystem.","solutions":["Run the exact `command:` printed in the error in a terminal to see why sudo refused","Grant the user passwordless sudo for the needed commands (chown, mv, cat on the exports path) or run vagrant from an interactive shell so the sudo prompt works","Make /etc/exports writable by your user (chmod/chown) so the sudo path is never taken","Then `vagrant reload` to retry the exports install"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Fail fast when sudo cannot run non-interactively (exports install needs chown/mv)\nsystem(\"sudo -n true 2>/dev/null\") || abort \"Configure passwordless sudo (or run vagrant in an interactive shell)\"","typeGuard":null,"tryCatchPattern":"begin\n  HostLinux::Cap::NFS.nfs_export(env, ui, id, ips, folders)\nrescue Vagrant::Errors::NFSExportsFailed => e\n  puts \"command failed: #{e.data[:command]}\\nstderr: #{e.data[:stderr]}\"\n  raise\nend","preventionTips":["Configure NOPASSWD sudo for chown/mv/cat on the exports path on CI/daemon hosts","Run vagrant from an interactive shell when passworded sudo is in play","Keep /etc/exports ownership stable so the chown branch rarely runs"],"tags":["nfs","linux","sudo","exports","permissions"],"backgroundTag":"sudo-permission-denied","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}