summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2024-04-23 20:15:30 +0200
committergit <svn-admin@ruby-lang.org>2024-04-29 08:57:35 +0000
commitd6cb62a88f4d31548dfedd1cdb4082be8b7ced2e (patch)
treef9c056ee90ece94f00e059d7b12140d4ac9e9287
parent68a1867f53c5343a72a436fe75eccafdbcb41ce0 (diff)
[rubygems/rubygems] Show better error when installed gemspecs are unreadable
https://github.com/rubygems/rubygems/commit/924f87c8a9
-rw-r--r--lib/bundler/rubygems_ext.rb12
-rw-r--r--spec/bundler/commands/install_spec.rb23
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index e0582beba2..a7539f4adb 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -146,6 +146,18 @@ module Gem
end
end
+ module BetterPermissionError
+ def data
+ Bundler::SharedHelpers.filesystem_access(loaded_from, :read) do
+ super
+ end
+ end
+ end
+
+ class StubSpecification
+ prepend BetterPermissionError
+ end
+
class Dependency
include ::Bundler::ForcePlatform
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
index f0c9aaea8e..1e57414377 100644
--- a/spec/bundler/commands/install_spec.rb
+++ b/spec/bundler/commands/install_spec.rb
@@ -1024,6 +1024,29 @@ RSpec.describe "bundle install with gem sources" do
end
end
+ describe "when gemspecs are unreadable", :permissions do
+ let(:gemspec_path) { vendored_gems("specifications/rack-1.0.0.gemspec") }
+
+ before do
+ gemfile <<~G
+ source "#{file_uri_for(gem_repo1)}"
+ gem 'rack'
+ G
+ bundle "config path vendor/bundle"
+ bundle :install
+ expect(out).to include("Bundle complete!")
+ expect(err).to be_empty
+
+ FileUtils.chmod("-r", gemspec_path)
+ end
+
+ it "shows a good error" do
+ bundle :install, raise_on_error: false
+ expect(err).to include(gemspec_path.to_s)
+ expect(err).to include("grant read permissions")
+ end
+ end
+
context "after installing with --standalone" do
before do
install_gemfile <<-G