{"record":{"id":"9fa26ebc5ba02937","repo":"hashicorp/vagrant","slug":"nfs-is-reporting-that-your-exports-file-is-invalid","errorCode":null,"errorMessage":"NFS is reporting that your exports file is invalid. Vagrant does\nthis check before making any changes to the file. Please correct\nthe issues below and execute \"vagrant reload\":\n\n%{output}","messagePattern":"NFS is reporting that your exports file is invalid\\. Vagrant does\nthis check before making any changes to the file\\. Please correct\nthe issues below and execute \"vagrant reload\":\n\n%(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::NFSBadExports","httpStatus":null,"severity":"error","filePath":"plugins/hosts/bsd/cap/nfs.rb","lineNumber":212,"sourceCode":"          command = []\n          command << \"sudo\" if !File.writable?(\"/etc/exports\")\n          command += [\n            \"sed\", \"-E\", \"-e\",\n            \"/^# VAGRANT-BEGIN:( #{user})? #{id}/,\" +\n            \"/^# VAGRANT-END:( #{user})? #{id}/ d\",\n            \"-ibak\",\n            \"/etc/exports\"\n          ]\n\n          # Use sed to just strip out the block of code which was inserted\n          # by Vagrant, and restart NFS.\n          system(*command)\n        end\n\n        def self.nfs_checkexports!\n          r = Vagrant::Util::Subprocess.execute(\"nfsd\", \"checkexports\")\n          if r.exit_code != 0\n            raise Vagrant::Errors::NFSBadExports, output: r.stderr\n          end\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":194,"sourceCodeEnd":219,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/hosts/bsd/cap/nfs.rb#L194-L219","documentation":"Vagrant::Errors::NFSBadExports is raised by HostBSD::Cap::NFS.nfs_checkexports! right after Vagrant rewrites /etc/exports on a BSD/macOS host. Vagrant runs `nfsd checkexports` to validate the file with the OS before committing to using it, and embeds the command's stderr as %{output}. A failure means the generated VAGRANT block, or pre-existing hand-edited entries, are syntactically or semantically invalid for your nfsd.","triggerScenarios":"A BSD/macOS host with one or more `type: \"nfs\"` synced folders runs `vagrant up`/`vagrant reload`; Vagrant regenerates the # VAGRANT-BEGIN/END block in /etc/exports and executes `nfsd checkexports` (plugins/hosts/bsd/cap/nfs.rb:210). Any non-zero exit — malformed option list, invalid network/CIDR token, duplicate exports of one directory with conflicting options, or stray lines someone added by hand — triggers the raise.","commonSituations":"Hand-edited /etc/exports left with a typo; the same host directory exported by two synced folders with different options; a stale entry whose client IP/CIDR no longer matches any interface; options like alldirs/maproot used in a form the host's nfsd rejects.","solutions":["Read the %{output} block in the error — nfsd names the exact offending line(s) of /etc/exports","Fix or delete the invalid lines; if they sit inside `# VAGRANT-BEGIN`/`# VAGRANT-END`, remove the whole block so Vagrant regenerates it from scratch","Validate manually with `nfsd checkexports` until it exits 0","Run `vagrant reload` so Vagrant rewrites and revalidates the exports"],"exampleFix":"# before — Vagrantfile exports the same host dir twice with different options\nconfig.vm.synced_folder \"/shared\", \"/srv/a\", type: \"nfs\", mount_options: [\"ro\"]\nconfig.vm.synced_folder \"/shared\", \"/srv/b\", type: \"nfs\", mount_options: [\"rw\"]\n# after — one consistent permission set per host path\nconfig.vm.synced_folder \"/shared\", \"/srv/a\", type: \"nfs\", mount_options: [\"rw\"]\nconfig.vm.synced_folder \"/shared\", \"/srv/b\", type: \"nfs\", mount_options: [\"rw\"]","handlingStrategy":"validation","validationCode":"# Pre-flight on BSD/macOS: let nfsd validate /etc/exports before vagrant touches it\nsystem(\"nfsd checkexports\")\nabort \"Fix /etc/exports first (see output above)\" unless $?.success?","typeGuard":null,"tryCatchPattern":"begin\n  machine.action_reload\nrescue Vagrant::Errors::NFSBadExports => e\n  puts \"nfsd rejected /etc/exports:\\n#{e.data[:output]}\"\n  # surface offending lines, offer to strip the VAGRANT block, then retry once fixed\n  raise\nend","preventionTips":["Lint /etc/exports with `nfsd checkexports` after every manual edit","Never export the same host directory twice with different options","After destroying VMs, check that no stale # VAGRANT-BEGIN/END blocks remain in /etc/exports"],"tags":["nfs","bsd","macos","exports","synced-folders"],"backgroundTag":"nfs-exports-invalid","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}