Skip to content

Commit e0bb8bf

Browse files
Improve command suggestion when gems are missing
Previous attempt to use a full path when the running version is different than the one that would be activated by default are different was not correct. This is because if this error happens in a `bundle exec` context, the `Gem.loaded_specs` is cleared because we're in an exec'd process, so will be always using a full path in these cases. This alternative approach should do what I was expecting.
1 parent 599fa57 commit e0bb8bf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bundler/lib/bundler/setup.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
Bundler.ui.error e.message
1313
Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"]
1414
if e.is_a?(Bundler::GemNotFound)
15-
suggested_bundle = Gem.loaded_specs["bundler"] ? "bundle" : Bundler::SharedHelpers.bundle_bin_path
15+
default_bundle = Gem.bin_path("bundler", "bundle")
16+
current_bundle = Bundler::SharedHelpers.bundle_bin_path
17+
suggested_bundle = default_bundle == current_bundle ? "bundle" : current_bundle
1618
suggested_cmd = "#{suggested_bundle} install"
1719
original_gemfile = Bundler.original_env["BUNDLE_GEMFILE"]
1820
suggested_cmd += " --gemfile #{original_gemfile}" if original_gemfile

0 commit comments

Comments
 (0)