summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <[email protected]>2024-10-21 20:43:23 +0200
committergit <[email protected]>2024-10-23 11:16:53 +0000
commit438d36eb4be447e1f4d244ec3801c53b1a8fcb1f (patch)
treeb9eb2f4cf52f3ea4b465ae470881a7bd15404653
parentf2380081dfcdc820e55e257a7c370064c058ee98 (diff)
[rubygems/rubygems] Print a proper error when there's a previous empty installation path with bad permissions
https://github.com/rubygems/rubygems/commit/07e7f0bf5e
-rw-r--r--lib/bundler/rubygems_gem_installer.rb4
-rw-r--r--spec/bundler/commands/install_spec.rb30
2 files changed, 33 insertions, 1 deletions
diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb
index 65fdf16072..1af1b85ff0 100644
--- a/lib/bundler/rubygems_gem_installer.rb
+++ b/lib/bundler/rubygems_gem_installer.rb
@@ -23,7 +23,9 @@ module Bundler
FileUtils.mkdir_p gem_dir, mode: 0o755
end
- extract_files
+ SharedHelpers.filesystem_access(gem_dir, :write) do
+ extract_files
+ end
build_extensions if spec.extensions.any?
write_build_info_file
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
index a47f62464f..6cd9964008 100644
--- a/spec/bundler/commands/install_spec.rb
+++ b/spec/bundler/commands/install_spec.rb
@@ -924,6 +924,36 @@ RSpec.describe "bundle install with gem sources" do
end
end
+ describe "when there's an empty install folder (like with default gems) without cd permissions", :permissions do
+ let(:full_gem_path) { bundled_app("vendor/#{Bundler.ruby_scope}/gems/myrack-1.0.0") }
+
+ before do
+ FileUtils.mkdir_p(full_gem_path)
+ gemfile <<-G
+ source "https://gem.repo1"
+ gem 'myrack'
+ G
+ end
+
+ it "should display a proper message to explain the problem" do
+ FileUtils.chmod("-x", full_gem_path)
+ bundle "config set --local path vendor"
+
+ begin
+ bundle :install, raise_on_error: false
+ ensure
+ FileUtils.chmod("+x", full_gem_path)
+ end
+
+ expect(err).not_to include("ERROR REPORT TEMPLATE")
+
+ expect(err).to include(
+ "There was an error while trying to write to `#{full_gem_path}`. " \
+ "It is likely that you need to grant write permissions for that path."
+ )
+ end
+ end
+
describe "when bundle bin dir does not have cd permission", :permissions do
let(:bin_dir) { bundled_app("vendor/#{Bundler.ruby_scope}/bin") }