97

我正在尝试使用这些说明设置 Discourse 开发环境。但是,当我运行 Vagrant 时,出现错误:

NFS 报告您的导出文件无效。Vagrant 在对文件进行任何更改之前会进行此检查。请更正以下问题并执行“vagrant reload”:

无法打开 /etc/exports

我查了一下,没有 etc/exports 文件夹,所以我创建了一个并运行vagrant reload. 这让我:

/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' 来自 /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' 来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/synced_folder_cleanup.rb:22:ineach_key' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/synced_folder_cleanup.rb:22:in来自 /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' 来自 /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' 来自 /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/prepare_forwarded_port_collision_params.rb:30:in来自 /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' 来自 /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' 来自 /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 '来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4 的 /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'。 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' 来自 /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'来自 /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阻止来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' 的 finalize_action' 来自 /Applications/Vagrant/embedded/gems/gems/vagrant -1.4.1/lib/vagrant/action/runner.rb:69:in busy' 来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:来自/Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in run' 来自 /Applications/Vagrant/embedded/gems/gems/vagrant- 1.4.1/lib/vagrant/action/builtin/call.rb:51:in call' 来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/config_validate.rb :25:在call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in call' 的 finalize_action' 来自 /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' 来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/util/busy.rb: 19:busy' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:in运行中'来自/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'来自/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' 来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb :34:在call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builder.rb:116:inblock in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/util/busy.rb:19:inrun' 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:95:in块在 finalize_action' 来自 /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' 来自 /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' 来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/util/busy.rb:19 :在busy' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:incall' 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' 来自 /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' 来自 /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' 来自 /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' 来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action /builtin/config_validate.rb:25:incall' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in来自 /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' 来自 /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' 来自 /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 '来自/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'来自/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' 来自 /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'来自 /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来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4 的 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:34:in busy' 的.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' 来自 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/commands/reload/command.rb:37:inblock in execute' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/plugin/v2/command.rb:193:in块在 /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/plugin/v2/command.rb:191 中的each' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/plugin/v2/command.rb:191:inwith_target_vms 中:在 /Applications/Vagrant/embedded/gems/gems/中的 with_target_vms 中vagrant-1.4.1/plugins/commands/reload/command.rb:36:inexecute' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/cli.rb:38:in从 /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' 来自 /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:inload' from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in'

我在 Mac (OS X 10.6.8) 上。我该如何解决?我尝试搜索原始错误消息,但我发现的只是一些包含抛出它的 Vagrant 源代码的存储库。

4

9 回答 9

336

我在 VirtualBox 安装中安装了一些以前的图像/框,因此已经有一些无效条目/etc/exports。所以我不得不清理那个文件并重新启动我的 Vagrant 盒子。

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":

这是我在主机上所做的:

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

vagrant halt
vagrant up --provision
于 2014-02-01T11:58:04.303 回答
79

我在 OS X 10.9 Mavericks (13A603) 上使用 Vagrant 1.4.1 和 VirtualBox 4.3.6 遇到了这个问题。我可以用一个简单的命令来修复它,以创建丢失的 /etc/exports 文件。正如下面的评论中所指出的,在 OS X 上运行,而不是 guest。

$ sudo touch /etc/exports

然后我就可以成功运行了vagrant up。我确实遇到了另一个错误,即 Guest Additions 不是最新的,但我通过安装 vagrant-vbguest 插件解决了这个问题。

$ vagrant plugin install vagrant-vbguest

然后很快vagrant reload我就开始运行了!

于 2013-12-23T19:37:07.520 回答
23

对我来说,这个错误开始出现在一个工作的 Vagrant 环境中。

我已经重命名了 Vagrant 运行的目录。为了修复它,我运行了“sudo vi /etc/exports”并修复了路径名,使其指向我的当前目录。

于 2014-04-11T14:02:56.780 回答
9

这样的事情我也经历过。我从另一个项目复制了我的 Vagrantfile,却忘记更改 NFS 设置。这导致当前 VM 挂载了我从中复制原始 Vagrantfile 的 VM 的父文件夹。所以我这样做了:

vagrant halt
vagrant up

仍然得到同样的错误。所以我找到了位于/etc/exports的导出文件,如下所示:

# 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

最后两条路径相同。所以我删除了最后三行并运行:

vagrant halt && vagrant up

现在一切似乎都运行良好。

OSX 10.11.1 流浪者 1.7.4

于 2015-11-22T07:47:40.547 回答
8

我不想经历降级的麻烦。这就是我所做的(仍然需要一段时间,但比降级恕我直言要少麻烦):

  1. 在 VM Vagrantfile 中,对于任何同步的文件夹,禁用 NFS

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

  2. 删除 /etc/exports

    sudo mv /etc/exports ~/Desktop/exports

  3. 重写 /etc/exports

    vagrant up

  4. 如果您希望/需要在 VM 上启用 NFS,请重新启用它

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

于 2014-01-17T20:08:28.157 回答
6

只需运行以下命令:

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

如果您不确定它不会覆盖项目的当前状态,请不要使用。vagrant up --provision

于 2018-09-21T06:58:58.980 回答
0

在 Ubuntu 12 主机/Ubuntu 12 来宾上,以下内容适用于我的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

注意:我还必须将由 Vagrant 确定的主机 IP 地址和由 Vagrant 确定的访客 IP 地址添加到防火墙例外。

于 2014-02-10T21:40:06.230 回答
0

我跑了vagrant box list这个告诉我有4个流浪盒子(一定是在某个时候不小心创建了它们——我通常只使用一个。所以然后我跑了vagrant box prune,它删除了我未使用的盒子。然后又vagrant up开始工作了!

于 2020-10-22T17:26:30.973 回答
-33

尝试使用 Discourse 中提到的已知良好版本的 VirtualBox 和 Vagrant作为您的第一个 Rails 应用程序

我在 Mac (OS X 10.9 (Mavericks)) 上遇到了同样的问题,但回滚到这些版本似乎为我解决了这个问题。

于 2013-12-22T22:54:11.887 回答