diff options
| author | Daisuke Aritomo <osyoyu@osyoyu.com> | 2025-12-04 20:56:31 +0900 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2026-01-15 16:16:16 +0900 |
| commit | 270c7fcec126d9de07488205cfa11b6ab37bc191 (patch) | |
| tree | 18aa9165aaa286b4d51e436fcbe7a2c5869c9ce3 | |
| parent | 943b0859498c5a49242e6f8563b1f518599fff0f (diff) | |
Fake BUNDLE_GEMFILE and BUNDLE_LOCKFILE to let checks pass
Bundler::Runtime#setup requires a real existing lockfile (see
Bundler::SharedHelpers#default_lockfile).
| -rw-r--r-- | lib/bundled_gems.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb index 0b6ae60b5f..429b34bef0 100644 --- a/lib/bundled_gems.rb +++ b/lib/bundled_gems.rb @@ -209,13 +209,24 @@ module Gem::BUNDLED_GEMS # :nodoc: builder = Bundler::Dsl.new + lockfile = nil if Bundler::SharedHelpers.in_bundle? && Bundler.definition.gemfiles.size > 0 Bundler.definition.gemfiles.each {|gemfile| builder.eval_gemfile(gemfile) } + lockfile = begin + Bundler.default_lockfile + rescue Bundler::GemfileNotFound + nil + end + else + # Fake BUNDLE_GEMFILE and BUNDLE_LOCKFILE to let checks pass + orig_gemfile = ENV["BUNDLE_GEMFILE"] + orig_lockfile = ENV["BUNDLE_LOCKFILE"] + Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", "Gemfile" + Bundler::SharedHelpers.set_env "BUNDLE_LOCKFILE", "Gemfile.lock" end builder.gem gem - lockfile = Bundler.default_lockfile definition = builder.to_definition(lockfile, nil) definition.validate_runtime! @@ -232,6 +243,8 @@ module Gem::BUNDLED_GEMS # :nodoc: rescue Bundler::GemNotFound warn "Failed to activate #{gem}, please install it with 'gem install #{gem}'" ensure + ENV['BUNDLE_GEMFILE'] = orig_gemfile if orig_gemfile + ENV['BUNDLE_LOCKFILE'] = orig_lockfile if orig_lockfile Bundler.ui = orig_ui Bundler::Definition.no_lock = orig_no_lock end |
