【问题标题】:Input/output error using Vagrant & winnfsd使用 Vagrant 和 winnfsd 的输入/输出错误
【发布时间】:2015-03-10 21:06:05
【问题描述】:

我正在使用vagrant-winnfsd 插件在 Windows 8.1 主机上通过 Vagrant 添加 NFS 支持。我正在运行 Ubuntu 14.04 来宾。

我正在使用此设置来运行 Rails 应用程序。一切运行良好,除了 Rails/Carrierwave 尝试从 tmp 目录中删除文件时产生此错误:

Errno::EIO (Input/output error @ dir_s_rmdir - /vagrant/myproject/public/uploads/tmp/1421108602-18479-5242):

这是我的 Vagrant 文件的相关部分:

config.vm.network "private_network", type: "dhcp"
config.vm.synced_folder ".", "/vagrant", type: "nfs"

关于如何解决这个问题的任何想法?

【问题讨论】:

  • 这些文件是从客户机创建的还是已经存在于主机上?有没有可能这是某种权限错误?
  • @MichaelS 文件上传到主机,临时文件由运行在客户机上的应用创建
  • 看起来这是 winnfsd 的问题:github.com/GM-Alex/vagrant-winnfsd/issues/22
  • @MichaelS 是的,我希望有人能找到解决方法
  • 好吧,我猜你不使用 Virtualbox 的共享文件夹,因为它慢得要命,但是 SMB 而不是 NFS 呢?

标签: ruby-on-rails-4 vagrant windows-8.1 ubuntu-14.04 nfs


【解决方案1】:

我终于能够使用其中一张 GitHub 票证中建议的 this approach 解决此问题。

基本上,它涉及将 Rails 和 Carrierwave 指向 /vagrant 文件夹之外的目录,以将 tmp 文件转储到其中以避免遇到任何锁定/权限问题:

# config/initializers/01_patch_tmpdir.rb

class Dir
  def self.tmpdir
    '/home/vagrant/rails_tmp/'
  end
end

CarrierWave.configure do |config|
  config.cache_dir = '/home/vagrant/uploads_tmp/tmp/uploads'
  config.root = '/home/vagrant/uploads_tmp/tmp'
end

ENV['TMPDIR'] = Dir.tmpdir

您现在可以继续将该文件添加到您的 .gitignore 中,这样它就不会妨碍其他人处理您的项目。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-02
    • 2021-10-04
    • 1970-01-01
    • 2015-06-17
    • 2016-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多