ruby-changes:72001
From: David <ko1@a...>
Date: Mon, 30 May 2022 00:28:01 +0900 (JST)
Subject: [ruby-changes:72001] 08b82e6b40 (master): [rubygems/rubygems] Ignore `Errno::EROFS` errors when creating `bundler.lock`
https://git.ruby-lang.org/ruby.git/commit/?id=08b82e6b40 From 08b82e6b40b1dbbff20ba609d7d5eb8106a2d346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Sun, 29 May 2022 15:30:44 +0200 Subject: [rubygems/rubygems] Ignore `Errno::EROFS` errors when creating `bundler.lock` Apparently old versions of MacOS would set `GEM_HOME` to a `/System` folder, and trying to create a file there raises `Errno::EROFS`. We ignore the error. Any permission issues should be better handled further down the line. https://github.com/rubygems/rubygems/commit/ef90c071d0 --- lib/bundler/process_lock.rb | 2 +- spec/bundler/install/process_lock_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/bundler/process_lock.rb b/lib/bundler/process_lock.rb index af7cd8a05f..0297f80e2c 100644 --- a/lib/bundler/process_lock.rb +++ b/lib/bundler/process_lock.rb @@ -12,7 +12,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/process_lock.rb#L12 yield f.flock(File::LOCK_UN) end - rescue Errno::EACCES, Errno::ENOLCK, Errno::ENOTSUP, Errno::EPERM + rescue Errno::EACCES, Errno::ENOLCK, Errno::ENOTSUP, Errno::EPERM, Errno::EROFS # 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. diff --git a/spec/bundler/install/process_lock_spec.rb b/spec/bundler/install/process_lock_spec.rb index e2b8d20607..1f8c62f26e 100644 --- a/spec/bundler/install/process_lock_spec.rb +++ b/spec/bundler/install/process_lock_spec.rb @@ -42,5 +42,16 @@ RSpec.describe "process lock spec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/process_lock_spec.rb#L42 expect(processed).to eq true end end + + context "when creating a lock raises Errno::EROFS" do + before { allow(File).to receive(:open).and_raise(Errno::EROFS) } + + 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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/