Skip to content

Commit d0dccdd

Browse files
committed
Add Errno::EROFS exception handling for read-only file systems
1 parent d4a23fc commit d0dccdd

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

changelog/fix_errno_erofs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#12625](https://github.com/rubocop/rubocop/pull/12625): Fix an error when server cache dir has read-only file system. ([@Strzesia][])

lib/rubocop/server/cache.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def stderr_path
117117

118118
def pid_running?
119119
Process.kill(0, pid_path.read.to_i) == 1
120-
rescue Errno::ESRCH, Errno::ENOENT, Errno::EACCES
120+
rescue Errno::ESRCH, Errno::ENOENT, Errno::EACCES, Errno::EROFS
121121
false
122122
end
123123

spec/rubocop/server/cache_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,15 @@
292292
end
293293
expect(described_class.pid_running?).to be(false)
294294
end
295+
296+
it 'works properly when the file system is read-only' do
297+
expect(described_class).to receive(:pid_path).and_wrap_original do |method|
298+
result = method.call
299+
allow(result).to receive(:read).and_raise(Errno::EROFS)
300+
result
301+
end
302+
expect(described_class.pid_running?).to be(false)
303+
end
295304
end
296305
end
297306
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy