Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input/output error using Vagrant & winnfsd

I'm using vagrant-winnfsd plugin to add NFS support with Vagrant on a Windows 8.1 host. I'm running Ubuntu 14.04 guest.

I'm using this setup to run a Rails app. Everything runs great except for when Rails/Carrierwave tries to delete files from the tmp dir which generates this error:

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

Here's the relavent portion of my Vagrant file:

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

Any ideas on how to resolve that?

like image 732
jesal Avatar asked Jan 13 '15 00:01

jesal


1 Answers

I was finally able to resolve this issue by using this approach suggested in one of the GitHub tickets.

Basically it involves pointing Rails and Carrierwave to a dir outside of the /vagrant folder to dump the tmp files into in order to avoid running into any lock/permission issues:

# 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

You can now go ahead and add that file to your .gitignore so it doesn't get in the way of other people working on your project.

like image 143
jesal Avatar answered Nov 11 '22 23:11

jesal