Skip to content

Commit

Permalink
Merge pull request #7603 from rubygems/deivid-rodriguez/better-unread…
Browse files Browse the repository at this point in the history
…able-error

Show better error when installed gemspecs are unreadable
  • Loading branch information
deivid-rodriguez committed Apr 29, 2024
2 parents 1d8f066 + 924f87c commit 4e7e56f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bundler/lib/bundler/rubygems_ext.rb
Expand Up @@ -146,6 +146,18 @@ def dependencies_to_gemfile(dependencies, group = nil)
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

Expand Down
23 changes: 23 additions & 0 deletions bundler/spec/commands/install_spec.rb
Expand Up @@ -1024,6 +1024,29 @@ def run
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
Expand Down

0 comments on commit 4e7e56f

Please sign in to comment.