module Bundler::SharedHelpers

def filesystem_access(path, action = :write, &block)

Other tags:
    See: {Bundler::PermissionError} -

Raises:
  • (Bundler::TemporaryResourceError) - if Errno:EAGAIN is raised in the
  • (Bundler::PermissionError) - if Errno:EACCES is raised in the

Other tags:
    Yield: - path

Parameters:
  • action (Symbol, #to_s) -- the type of operation that will be
  • path (String) -- the path that the action will be attempted to
def filesystem_access(path, action = :write, &block)
  # Use block.call instead of yield because of a bug in Ruby 2.2.2
  # See https://github.com/bundler/bundler/issues/5341 for details
  block.call(path.dup.untaint)
rescue Errno::EACCES
  raise PermissionError.new(path, action)
rescue Errno::EAGAIN
  raise TemporaryResourceError.new(path, action)
rescue Errno::EPROTO
  raise VirtualProtocolError.new
rescue Errno::ENOSPC
  raise NoSpaceOnDeviceError.new(path, action)
rescue *[const_get_safely(:ENOTSUP, Errno)].compact
  raise OperationNotSupportedError.new(path, action)
rescue Errno::EEXIST, Errno::ENOENT
  raise
rescue SystemCallError => e
  raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
end