diff options
-rw-r--r-- | lib/rubygems/installer.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_install_command.rb | 6 |
2 files changed, 7 insertions, 3 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 diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 0c4e1efc78..c38c94e5e2 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -193,7 +193,7 @@ ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in a pend "skipped in root privilege" if Process.uid.zero? spec_fetcher do |fetcher| - fetcher.gem "a", 2 + fetcher.download "a", 2 end @cmd.options[:user_install] = false @@ -204,12 +204,14 @@ ERROR: Could not find a valid gem 'bar' (= 0.5) (required by 'foo' (>= 0)) in a FileUtils.chmod 0o755, @userhome FileUtils.chmod 0o555, @gemhome - assert_raise Gem::FilePermissionError do + assert_raise Gem::MockGemUi::SystemExitException, @ui.error do @cmd.execute end ensure FileUtils.chmod 0o755, @gemhome end + + assert_equal %w[a-2], @cmd.installed_specs.map(&:full_name).sort end def test_execute_local_missing |