97

I am trying to set up the Discourse development environment using these instructions. However when I run Vagrant I get the error:

NFS is reporting that your exports file is invalid. Vagrant does this check before making any changes to the file. Please correct the issues below and execute "vagrant reload":

Can't open /etc/exports

I checked, and I don't have an etc/exports folder, so I created one and ran vagrant reload. This got me:

/Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/hosts/bsd/host.rb:146:in read': Is a directory - /etc/exports (Errno::EISDIR) from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/hosts/bsd/host.rb:146:innfs_prune' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/synced_folders/nfs/synced_folder.rb:68:in cleanup' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/synced_folder_cleanup.rb:24:inblock in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/synced_folder_cleanup.rb:22:in each_key' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/synced_folder_cleanup.rb:22:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/providers/virtualbox/action/prepare_nfs_valid_ids.rb:12:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:118:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb:30:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/env_set.rb:19:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/provision.rb:52:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/providers/virtualbox/action/clear_forwarded_ports.rb:13:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/providers/virtualbox/action/set_name.rb:19:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/providers/virtualbox/action/clean_machine_folder.rb:17:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/providers/virtualbox/action/check_accessible.rb:18:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:95:inblock in finalize_action' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builder.rb:116:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:inblock in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/util/busy.rb:19:in busy' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:inrun' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/call.rb:51:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:95:in block in finalize_action' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builder.rb:116:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:in block in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/util/busy.rb:19:inbusy' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/call.rb:51:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:95:inblock in finalize_action' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builder.rb:116:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:inblock in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/util/busy.rb:19:in busy' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:inrun' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/call.rb:51:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/config_validate.rb:25:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/call.rb:57:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/config_validate.rb:25:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:95:in block in finalize_action' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builder.rb:116:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:in block in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/util/busy.rb:19:inbusy' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/call.rb:51:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/providers/virtualbox/action/check_virtualbox.rb:17:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builder.rb:116:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:in block in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/util/busy.rb:19:inbusy' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/machine.rb:147:inaction' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/commands/reload/command.rb:37:in block in execute' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/plugin/v2/command.rb:193:inblock in with_target_vms' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/plugin/v2/command.rb:191:in each' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/plugin/v2/command.rb:191:inwith_target_vms' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/commands/reload/command.rb:36:in execute' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/cli.rb:38:inexecute' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/environment.rb:484:in cli' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/bin/vagrant:127:in' from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in load' from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in'

I am on a Mac (OS X 10.6.8). How do I fix this? I tried searching for the original error message, and all I found was a few repositories containing the Vagrant source code that throws it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hunter
  • 995
  • 1
  • 8
  • 7

9 Answers9

336

I had some previous images/boxes installed in my VirtualBox installation, so there were a few invalid entries in /etc/exports already. So I had to clean up that file and restart my Vagrant box.

NFS is reporting that your exports file is invalid. Vagrant does
this check before making any changes to the file. Please correct
the issues below and execute "vagrant reload":

Here's what I did on my host machine:

sudo rm /etc/exports
sudo touch /etc/exports

vagrant halt
vagrant up --provision
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
totas
  • 10,288
  • 6
  • 35
  • 32
  • 9
    This was the most applicable one, as I had two vagrant boxes mounting the same folder. They got confused! – wulftone May 22 '14 at 23:11
  • 34
    or instead of delete all, just remove all those lines related to those VM's that are not anymore there. – Alejandro Moreno Oct 22 '14 at 12:04
  • 3
    I had this issue after renaming the project dir name. Thanks! :) – Radu Sep 07 '15 at 13:28
  • 2
    or you can just simply edit the file with correct path – Volatil3 Sep 12 '15 at 07:28
  • This worked for me too. But I did get an error saying Vagrant could not read the exports file due to a permissions error. I had to run: sudo chmod 655 /etc/exports Then it worked. – rcd Sep 24 '15 at 16:04
  • 4
    It can be worth to mention that this command should be executed on host machine. Because by vagrant box is actually booted, I could log in to it, but couldn't find /etc/exports file. Because it is on host machine. – chuwy Mar 18 '16 at 12:43
  • Instead of deleting the whole file you can just edit it and remove old unused paths – Tiagojdferreira Jun 27 '16 at 08:45
  • This issue held me back, I had very old files from my early days testing in IE6 using virtual machines. – Olivier Butler Jul 29 '16 at 15:44
  • Additional step of "restart machine" after vagrant halt was required for me – Joel Davey Aug 01 '16 at 17:58
  • 4
    I'm not sure that the `--provision` flag is necessary in the last command, as typically NFS is mounted on `up` rather than at provisioning time. It may be required in your setup, but these steps worked for me without that flag. – acobster May 02 '17 at 17:26
  • This fixed it for me. This should be the accepted answer – ksealey Jan 18 '18 at 15:32
  • 1
    -- provision is not necessary and depending on what it does for you it can even be dangerous (i.e. import some starting database over most recent one). Instead, do just what vagrant says you should do: 'Please correct the issues below and execute "vagrant reload"'. For "correct the issue" do first 2 lines @totas suggested here. – MilanG Sep 21 '18 at 06:56
79

I ran into this issue with Vagrant 1.4.1 and VirtualBox 4.3.6 on OS X 10.9 Mavericks (13A603). I was able to fix it with a simple command to create the missing /etc/exports file. Run this on OS X, not guest, as pointed out in comments below.

$ sudo touch /etc/exports

I was then able to successfully run vagrant up. I did run into another error where the Guest Additions weren't up to date, but I fixed that issue by installing the vagrant-vbguest plugin.

$ vagrant plugin install vagrant-vbguest

and then a quick vagrant reload and I was up and running!

colinhoernig
  • 942
  • 6
  • 9
23

For me, this error started appearing for a working Vagrant environment.

I had renamed the directory Vagrant was running from. To fix it, I ran 'sudo vi /etc/exports' and fixed the pathname so it pointed to my current directory.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kevin G.
  • 585
  • 3
  • 5
9

The same thing happened to me. I copied over my Vagrantfile from another project and forgot to change the NFS settings. This caused the current VM to mount the parent folder of the VM that I copied the original Vagrantfile from. So I did this:

vagrant halt
vagrant up

Still got the same error. So I tracked down my exports file located at /etc/exports which looks like this:

# VAGRANT-BEGIN: 501 64e10d4d-342e-4f55-b69a-97edda35742f
"/Users/[username]/vagrant" 192.168.11.12 -alldirs -mapall=501:20
# VAGRANT-END: 501 64e10d4d-342e-4f55-b69a-97edda35742f
# VAGRANT-BEGIN: 501 b3c6e7fe-95d4-48db-8876-c89d3e07af8d
"/Users/[username]/Sites/molitech-oms" 192.168.11.124 -alldirs -mapall=501:20
# VAGRANT-END: 501 b3c6e7fe-95d4-48db-8876-c89d3e07af8d
# VAGRANT-BEGIN: 501 3e2aabfd-ce63-441b-85a2-1b51e8beb863
"/Users/[username]/Sites/app" 192.168.11.125 -alldirs -mapall=501:20
# VAGRANT-END: 501 3e2aabfd-ce63-441b-85a2-1b51e8beb863
# VAGRANT-BEGIN: 501 ff92e353-9f6d-48ee-9d76-e29b33f1dd60
"/Users/[username]/Sites" 192.168.11.126 -alldirs -mapall=501:20
# VAGRANT-END: 501 ff92e353-9f6d-48ee-9d76-e29b33f1dd60

The last two paths are the same. So I deleted the last three lines and ran:

vagrant halt && vagrant up

Now everything seems to be working fine.

OSX 10.11.1 Vagrant 1.7.4

colefner
  • 1,812
  • 1
  • 16
  • 11
8

I didn't want to go through the hassle of downgrading. This is what I did (still took a while, but less hassle than downgrading IMHO):

  1. In the VM Vagrantfile, for any synced folder, disabled NFS

    config.vm.synced_folder ".", "/vagrant", nfs: false

  2. Removed /etc/exports

    sudo mv /etc/exports ~/Desktop/exports

  3. Rewrite /etc/exports

    vagrant up

  4. Re-enable NFS if you want/need it enabled on your VM

    config.vm.synced_folder ".", "/vagrant", nfs: true

Lou Groshek
  • 718
  • 6
  • 23
6

Just run following commands:

sudo rm /etc/exports
sudo touch /etc/exports
vagrant reload

Do NOT use vagrant up --provision if you are not sure that it won't overwrite current status of your project.

MilanG
  • 6,994
  • 2
  • 35
  • 64
0

On Ubuntu 12 host/Ubuntu 12 guest the following worked for me with Discourse:

nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", type: "nfs", nfs_udp: "true", nfs_version: "4", :nfs => nfs_setting

Note: I also had to add a host IP address determined by Vagrant and guest IP address determined by Vagrant to firewall exceptions.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
niccolox
  • 91
  • 1
  • 2
0

i ran vagrant box list this showed me that there were 4 vagrant boxes (must have accidentally created them at some point - i usually only use one. So then I ran vagrant box prune , which deleted my unused boxes. then vagrant up started working again!

GMoney
  • 1
-33

Try using the known good versions of VirtualBox and Vagrant noted in Discourse as Your First Rails App:

I was having the same issue on Mac (OS X 10.9 (Mavericks)), but rolling back to these versions seemed to fix it for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lockyer
  • 1,311
  • 1
  • 13
  • 30
  • Thanks I'm still finishing the next installation steps, but it looks like that worked. – Hunter Dec 23 '13 at 00:09
  • 3
    Downgrading is not required. You just need to run `sudo touch /etc/exports`. See [colinhoernig's answer](http://stackoverflow.com/a/20750058/134014). Also, I just updated my vagrant install to v1.4.3 and VirtualBox to v4.3.8 and that seemed to solve my problem. – donut Mar 02 '14 at 18:02
  • 5
    this is a misleading answer. please select the colinhoemig's answer as its much more helpful! – enjalot Apr 15 '14 at 02:28
  • 3
    The answer is not constructive and missleading. I wonder how it is marked as correct. The correct answer is that of @colinhoernig that has been voted up more than 50 times. For the Error to be resolved. You need to fix the /etc/exports file. Then build again. – Alexandros Spyropoulos Aug 27 '15 at 10:36
  • 1
    When you're building a project with documented dependencies for the first time it helps to use the exact versions that are known to work, just because there's a work around for this one exact issue doesn't mean he wouldn't run into other undocumented incompatibilities... – Lockyer May 13 '16 at 19:45
  • It's been a long time, but still, you are my savior @Donut. – Pauloscorps Dec 12 '17 at 08:44