summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Aritomo <osyoyu@osyoyu.com>2025-12-03 02:25:46 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2026-01-20 10:49:33 -0800
commit83479483c96fdfffbde11af482c7fd920b0c1dea (patch)
treed7be53fd1b1f4bc592a7ef009b39a9fa0dcb3cf0
parent33cae95c8afce2782c2808a8e74c81d9ac763a4e (diff)
[Bug #21723] Let `binding.irb` properly load irb by fixing force_activate()
This patch fixes a problem where `binding.irb` (= force_activate('irb')) fails under `bundle exec` when the Gemfile does not contain `irb` and does contain a gem which is (1) not installed in GEM_HOME (2) sourced using `path:`/`git:`. The original approach constructing a temporary definition fails since it does not set the equalivent of `path:`/`git:`. Always reconstructing a definition from a Gemfile and applying lockfile constraints should be a more robust approach. [Bug #21723]
-rw-r--r--lib/bundled_gems.rb11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb
index 3ac10aa256..0b6ae60b5f 100644
--- a/lib/bundled_gems.rb
+++ b/lib/bundled_gems.rb
@@ -209,17 +209,14 @@ module Gem::BUNDLED_GEMS # :nodoc:
builder = Bundler::Dsl.new
- if Bundler::SharedHelpers.in_bundle?
- if Bundler.locked_gems
- Bundler.locked_gems.specs.each{|spec| builder.gem spec.name, spec.version.to_s }
- elsif Bundler.definition.gemfiles.size > 0
- Bundler.definition.gemfiles.each{|gemfile| builder.eval_gemfile(gemfile) }
- end
+ if Bundler::SharedHelpers.in_bundle? && Bundler.definition.gemfiles.size > 0
+ Bundler.definition.gemfiles.each {|gemfile| builder.eval_gemfile(gemfile) }
end
builder.gem gem
- definition = builder.to_definition(nil, true)
+ lockfile = Bundler.default_lockfile
+ definition = builder.to_definition(lockfile, nil)
definition.validate_runtime!
begin