Search code examples
rubyruby-on-rails-5rhel7

Rails 5 unable to write to NFS mount on RHEL7 Operation not supported copy_file_range


I am writing a Rails 5 application that will be deployed to a RHEL7 host that uses an NFS mount for storage.

The application uses the CarrierWave plugin to write uploaded files to an NFS mount on the RHEL7 host.

class ExampleUploader < CarrierWave::Uploader::Base

  # Choose what kind of storage to use for this uploader:
  storage :file

  def store_dir
    "#{Rails.root.to_s}/#{model.class.to_s.underscore}/#{model.id}"
  end

end

The code works in a local development environment (on a laptop), however, the same code stops working when deployed to the RHEL7 server.

Puma caught this error: Operation not supported - copy_file_range (Errno::EOPNOTSUPP)
/usr/local/lib/ruby/2.5.0/fileutils.rb:1293:in `copy_stream'
/usr/local/lib/ruby/2.5.0/fileutils.rb:1293:in `block (2 levels) in copy_file'
/usr/local/lib/ruby/2.5.0/fileutils.rb:1292:in `open'
/usr/local/lib/ruby/2.5.0/fileutils.rb:1292:in `block in copy_file'
/usr/local/lib/ruby/2.5.0/fileutils.rb:1291:in `open'
/usr/local/lib/ruby/2.5.0/fileutils.rb:1291:in `copy_file'
/usr/local/lib/ruby/2.5.0/fileutils.rb:432:in `copy_file'
/usr/local/lib/ruby/2.5.0/fileutils.rb:359:in `block in cp'
/usr/local/lib/ruby/2.5.0/fileutils.rb:1463:in `block in fu_each_src_dest'
/usr/local/lib/ruby/2.5.0/fileutils.rb:1479:in `fu_each_src_dest0'
/usr/local/lib/ruby/2.5.0/fileutils.rb:1461:in `fu_each_src_dest'
/usr/local/lib/ruby/2.5.0/fileutils.rb:358:in `cp'
/usr/local/bundle/gems/carrierwave-0.11.2/lib/carrierwave/sanitized_file.rb:213:in `copy_to'

Based on my research, copy_file_range function was disabled in RHEL7 and that's the low-level function that Ruby is supposed to be using to write files. So that means Ruby cannot write to an NFS mount on a RHEL7 host.

It looks like there was a recent update made but that simply changed the type of error message, it didn't actually fix the issue.

Question: What are our options for getting this to work? Are there any patches available for Ruby? Or do we need to deploy this on another operating system aside from RHEL7? If so, what OS actually supports Ruby writing to an NFS mount?


Solution

  • This was fixed after updating the host operating system to the latest version of RHEL7.