diff options
author | David Rodriguez <deivid.rodriguez@riseup.net> | 2021-10-14 12:03:57 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-10-25 20:48:51 +0900 |
commit | b4a43e4f577807303b0e465a27eefff2793fe3ea (patch) | |
tree | 034742921d7ba4295fa37b1e302f1fe59ded99cf /spec/bundler/commands/install_spec.rb | |
parent | 00412be20469407cd6da813eab6bfa5b63cd945f (diff) |
[rubygems/rubygems] Show proper error when previous installation of gem can't be deleted
Instead of showing the bug report template with an error at a random
place.
https://github.com/rubygems/rubygems/commit/882ad3ab57
Diffstat (limited to 'spec/bundler/commands/install_spec.rb')
-rw-r--r-- | spec/bundler/commands/install_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index a477369e4c..2c7f0360e6 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -708,6 +708,47 @@ RSpec.describe "bundle install with gem sources" do end end + describe "when the path of a specific gem is not writable", :permissions do + let(:gems_path) { bundled_app("vendor/#{Bundler.ruby_scope}/gems") } + let(:foo_path) { gems_path.join("foo-1.0.0") } + + before do + build_repo4 do + build_gem "foo", "1.0.0" do |s| + s.write "CHANGELOG.md", "foo" + end + end + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem 'foo' + G + end + + it "should display a proper message to explain the problem" do + bundle "config set --local path vendor" + bundle :install + expect(out).to include("Bundle complete!") + expect(err).to be_empty + + FileUtils.chmod("-x", foo_path) + + begin + bundle "install --redownload", :raise_on_error => false + ensure + FileUtils.chmod("+x", foo_path) + end + + expect(err).not_to include("ERROR REPORT TEMPLATE") + + expect(err).to include( + "There was an error while trying to delete `#{foo_path}`. " \ + "It is likely that you need to grant executable permissions for all parent directories " \ + "and write permissions for `#{gems_path}`, and the same thing for all subdirectories inside #{foo_path}." + ) + end + end + describe "when bundle cache path does not have write access", :permissions do let(:cache_path) { bundled_app("vendor/#{Bundler.ruby_scope}/cache") } |