summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <[email protected]>2023-11-27 15:57:45 -0600
committergit <[email protected]>2023-11-30 03:41:15 +0000
commit62e2e1da920d15e755f1826b3703ca81366526d8 (patch)
tree2f50b29ee69152f2af001ae66f7872224de40135
parentf2bb5394596c96ce5d7ff415694f3fc83715a96b (diff)
[rubygems/rubygems] Allow auto-install to install missing git gems
Currently, auto-install with git gems fails, when it would succeed with a rubygems-source gem Fix the issue by doing the same fallback for git errors as we do for missing gems, the git errors should only bubble up in these cases when the gem is not installed, meaning we want to go through the install flow (and any persistent errors will be raised through there) https://github.com/rubygems/rubygems/commit/e25a339f7a
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--spec/bundler/commands/exec_spec.rb17
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 1f7afe72d8..c2fa92d875 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -805,7 +805,7 @@ module Bundler
begin
Bundler.definition.specs
- rescue GemNotFound
+ rescue GemNotFound, GitError
Bundler.ui.info "Automatically installing missing gems."
Bundler.reset!
invoke :install, []
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb
index 14255dff60..760ab8dc86 100644
--- a/spec/bundler/commands/exec_spec.rb
+++ b/spec/bundler/commands/exec_spec.rb
@@ -615,6 +615,23 @@ RSpec.describe "bundle exec" do
expect(out).to include("Installing foo 1.0")
end
+ it "performs an automatic bundle install with git gems" do
+ build_git "foo" do |s|
+ s.executables = "foo"
+ end
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo1)}"
+ gem "rack", "0.9.1"
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
+ G
+
+ bundle "config set auto_install 1"
+ bundle "exec foo"
+ expect(out).to include("Fetching rack 0.9.1")
+ expect(out).to include("Fetching #{lib_path("foo-1.0")}")
+ expect(out.lines).to end_with("1.0")
+ end
+
it "loads the correct optparse when `auto_install` is set, and optparse is a dependency" do
if Gem.rubygems_version < Gem::Version.new("3.3.0.a")
skip "optparse is a default gem, and rubygems loads it during install"