diff options
-rw-r--r-- | lib/bundler/rubygems_gem_installer.rb | 4 | ||||
-rw-r--r-- | spec/bundler/commands/install_spec.rb | 30 |
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") } |