diff options
author | David RodrÃguez <[email protected]> | 2023-10-26 18:17:22 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-12-05 14:28:41 +0900 |
commit | 7ab877761e0577b1cd29811173971305bfadcead (patch) | |
tree | 635e730d8adcced37a42aaa0ec52751b57c357e5 /lib | |
parent | 4a71852f757d9c18c023f3f6e993cdf55f74411d (diff) |
[rubygems/rubygems] Instead of checking writability, try to write
Checking writability is prone to errors. For example:
$ mkdir -p foo/bar
$ chmod -w foo
$ touch foo/bar/baz # succeeds even if foo is not writable
https://github.com/rubygems/rubygems/commit/6056138b6a
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/installer.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 1e35e4fe83..aca42a03b0 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -351,6 +351,9 @@ class Gem::Installer run_post_install_hooks spec + rescue Errno::EACCES => e + # Permission denied - /path/to/foo + raise Gem::FilePermissionError, e.message.split(" - ").last end def run_pre_install_hooks # :nodoc: @@ -716,7 +719,6 @@ class Gem::Installer def verify_gem_home # :nodoc: FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0o755 - raise Gem::FilePermissionError, gem_home unless File.writable?(gem_home) end def verify_spec |