Sha256: 89a49a5e17154565324cade671e656f8651405797720addcb4d057f07c4a8c2f

Contents?: true

Size: 658 Bytes

Versions: 33

Compression:

Stored size: 658 Bytes

Contents

# frozen_string_literal: true

module Bundler
  class ProcessLock
    def self.lock(bundle_path = Bundler.bundle_path)
      lock_file_path = File.join(bundle_path, "bundler.lock")
      has_lock = false

      File.open(lock_file_path, "w") do |f|
        f.flock(File::LOCK_EX)
        has_lock = true
        yield
        f.flock(File::LOCK_UN)
      end
    rescue Errno::EACCES, Errno::ENOLCK, Errno::ENOTSUP
      # In the case the user does not have access to
      # create the lock file or is using NFS where
      # locks are not available we skip locking.
      yield
    ensure
      FileUtils.rm_f(lock_file_path) if has_lock
    end
  end
end

Version data entries

33 entries across 33 versions & 4 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/bundler-2.3.5/lib/bundler/process_lock.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/bundler-2.3.5/lib/bundler/process_lock.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/bundler-2.3.7/lib/bundler/process_lock.rb
rubygems-update-3.3.14 bundler/lib/bundler/process_lock.rb
bundler-2.3.14 lib/bundler/process_lock.rb
rubygems-update-3.3.13 bundler/lib/bundler/process_lock.rb
bundler-2.3.13 lib/bundler/process_lock.rb
rubygems-update-3.3.12 bundler/lib/bundler/process_lock.rb
bundler-2.3.12 lib/bundler/process_lock.rb
rubygems-update-3.3.11 bundler/lib/bundler/process_lock.rb
bundler-2.3.11 lib/bundler/process_lock.rb
rubygems-update-3.3.10 bundler/lib/bundler/process_lock.rb
bundler-2.3.10 lib/bundler/process_lock.rb
rubygems-update-3.3.9 bundler/lib/bundler/process_lock.rb
bundler-2.3.9 lib/bundler/process_lock.rb
rubygems-update-3.3.8 bundler/lib/bundler/process_lock.rb
bundler-2.3.8 lib/bundler/process_lock.rb
rubygems-update-3.3.7 bundler/lib/bundler/process_lock.rb
bundler-2.3.7 lib/bundler/process_lock.rb
rubygems-update-3.3.6 bundler/lib/bundler/process_lock.rb