Skip to content

Commit

Permalink
Ignore Errno::EPERM errors when creating bundler.lock
Browse files Browse the repository at this point in the history
This kind of error can happen when setting `GEM_HOME` to a path
under MacOS System Integrity Protection.

We ignore the error. Any permission issues should be better handled
further down the line.
  • Loading branch information
deivid-rodriguez committed May 29, 2022
1 parent a269631 commit 174cb66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bundler/lib/bundler/process_lock.rb
Expand Up @@ -12,7 +12,7 @@ def self.lock(bundle_path = Bundler.bundle_path)
yield
f.flock(File::LOCK_UN)
end
rescue Errno::EACCES, Errno::ENOLCK, Errno::ENOTSUP
rescue Errno::EACCES, Errno::ENOLCK, Errno::ENOTSUP, Errno::EPERM
# 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.
Expand Down
11 changes: 11 additions & 0 deletions bundler/spec/install/process_lock_spec.rb
Expand Up @@ -31,5 +31,16 @@
expect(processed).to eq true
end
end

context "when creating a lock raises Errno::EPERM" do
before { allow(File).to receive(:open).and_raise(Errno::EPERM) }

it "skips creating the lock file and yields" do
processed = false
Bundler::ProcessLock.lock(default_bundle_path) { processed = true }

expect(processed).to eq true
end
end
end
end

0 comments on commit 174cb66

Please sign in to comment.