【问题标题】:Vagrant error: NFS is reporting that your exports file is invalidVagrant 错误:NFS 报告您的导出文件无效
【发布时间】:2014-01-10 15:37:53
【问题描述】:

我正在尝试使用这些instructions 设置 Discourse 开发环境。但是,当我运行 Vagrant 时,我得到了错误:

NFS 报告您的导出文件无效。流浪者确实 在对文件进行任何更改之前进行此检查。请纠正 以下问题并执行“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:in each_key' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/builtin/synced_folder_cleanup.rb:22: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/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:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb:30: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/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.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' 来自 /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' 来自 /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:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/warden.rb:95:inblock 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:in busy' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:inrun' 来自 /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: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/lib/vagrant/action/warden.rb:95:inblock 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:in busy' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.4.1/lib/vagrant/action/runner.rb:69:inrun' 来自 /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/builtin/config_validate.rb:25: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/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: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: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: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/machine.rb:147:inaction' 来自 /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' 来自 /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' 来自 /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' 来自 /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:in load' from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in'

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

【问题讨论】:

    标签: export vagrant nfs discourse


    【解决方案1】:

    尝试使用 Discourse as Your First Rails App 中提到的已知良好版本的 VirtualBox 和 Vagrant:

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

    【讨论】:

    • 谢谢,我仍在完成接下来的安装步骤,但看起来可行。
    • 不需要降级。你只需要运行sudo touch /etc/exports。见colinhoernig's answer。另外,我刚刚将我的 vagrant install 更新到 v1.4.3,将 VirtualBox 更新到 v4.3.8,这似乎解决了我的问题。
    • 这是一个误导性的答案。请选择 colinhoemig 的答案,因为它更有帮助!
    • 答案没有建设性和误导性。我想知道它是如何被标记为正确的。正确的答案是被投票超过 50 次的@colinhoernig。为了解决错误。您需要修复 /etc/exports 文件。然后重新构建。
    • 当您第一次构建具有文档化依赖关系的项目时,使用已知可以工作的确切版本会有所帮助,仅仅因为有解决这个确切问题的方法并不意味着他不会遇到其他未记录的不兼容性...
    【解决方案2】:

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

    $ sudo touch /etc/exports
    

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

    $ vagrant plugin install vagrant-vbguest
    

    然后是一个快速的vagrant reload,然后我就开始运行了!

    【讨论】:

    • 非常好的提示,这必须在 Mac 主机上完成...不像我第一次尝试的那样在客户机上完成
    • 谢谢@Ramzi,我已经编辑了原文以澄清。
    • 我不得不在 linux 上使用 sudo rm -rf /etc/exports 因为它是一个文件夹
    • 我还必须编辑我的 /etc/exports 文件,因为它有多个让 vagrant 感到困惑的条目。
    • 我不得不删除导出文件的内容
    【解决方案3】:

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

    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

    【讨论】:

      【解决方案4】:

      我在 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
      

      【讨论】:

      • 这是最适用的一个,因为我有两个 vagrant box 安装在同一个文件夹中。他们搞糊涂了!
      • 或者不是全部删除,而是删除与那些不再存在的虚拟机相关的所有行。
      • 我在重命名项目目录名称后遇到了这个问题。谢谢! :)
      • 值得一提的是,这个命令应该在主机上执行。因为通过 vagrant box 实际启动,我可以登录它,但找不到 /etc/exports 文件。因为它在主机上。
      • 我不确定最后一个命令中是否需要 --provision 标志,因为 NFS 通常安装在 up 上,而不是在配置时。您的设置中可能需要它,但这些步骤在没有该标志的情况下对我有用。
      【解决方案5】:

      在 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 地址添加到防火墙例外。

      【讨论】:

        【解决方案6】:

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

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

        【讨论】:

          【解决方案7】:

          同样的事情也发生在我身上。我从另一个项目复制了我的 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

          【讨论】:

            【解决方案8】:

            只需运行以下命令:

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

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

            【讨论】:

              【解决方案9】:

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

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2015-05-03
                • 1970-01-01
                • 2016-04-25
                • 2013-04-27
                • 2018-07-07
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多