Skip to content

Commit 6a474ef

Browse files
deivid-rodriguezmatzbot
authored andcommitted
[rubygems/rubygems] Don't print bug report template when bin dir is not writable
rubygems/rubygems@f4ce3aae71
1 parent a1f72a5 commit 6a474ef

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

lib/bundler/rubygems_gem_installer.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def install
2929
write_build_info_file
3030
run_post_build_hooks
3131

32-
generate_bin
32+
SharedHelpers.filesystem_access(bin_dir, :write) do
33+
generate_bin
34+
end
35+
3336
generate_plugins
3437

3538
write_spec

spec/bundler/commands/install_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,36 @@ def run
871871
end
872872
end
873873

874+
describe "when bundle bin dir does not have write access", :permissions do
875+
let(:bin_dir) { bundled_app("vendor/#{Bundler.ruby_scope}/bin") }
876+
877+
before do
878+
FileUtils.mkdir_p(bin_dir)
879+
gemfile <<-G
880+
source "#{file_uri_for(gem_repo1)}"
881+
gem 'rack'
882+
G
883+
end
884+
885+
it "should display a proper message to explain the problem" do
886+
FileUtils.chmod("-x", bin_dir)
887+
bundle "config set --local path vendor"
888+
889+
begin
890+
bundle :install, raise_on_error: false
891+
ensure
892+
FileUtils.chmod("+x", bin_dir)
893+
end
894+
895+
expect(err).not_to include("ERROR REPORT TEMPLATE")
896+
897+
expect(err).to include(
898+
"There was an error while trying to write to `#{bin_dir}`. " \
899+
"It is likely that you need to grant write permissions for that path."
900+
)
901+
end
902+
end
903+
874904
describe "when bundle extensions path does not have write access", :permissions do
875905
let(:extensions_path) { bundled_app("vendor/#{Bundler.ruby_scope}/extensions/#{Gem::Platform.local}/#{Gem.extension_api_version}") }
876906

0 commit comments

Comments
 (0)