Skip to content

Commit 754c404

Browse files
committed
bundler/inline: perform installation from a forked child
Unless of course fork isn't available. Alternate: #7930, #7933 Fix: #7930, #7933 When bundler inline has to install gems, it loads more dependencies than when it goes through the fast path of all gems being installed. One of them is `securerandom` so if trying to use bundler/inline with a gem that have a dependency on securerandom that don't match the default version, the script fails with `Gem::LoadError`. This can be preproduced on Ruby 3.2.x, after making sure to `gem uninstall securerandom` so only the default gem remains, and then running the following script: ```ruby require 'bundler/inline' gemfile do source 'https://rubygems.org' gem 'activesupport', '7.2.0' # depends on securerandom >= 0.3 end require 'securerandom' ```
1 parent 633c1bf commit 754c404

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

bundler/lib/bundler/inline.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,21 @@ def definition.lock(*); end
5454
definition.validate_runtime!
5555

5656
if install || definition.missing_specs?
57-
Bundler.settings.temporary(inline: true, no_install: false) do
58-
installer = Bundler::Installer.install(Bundler.root, definition, system: true)
59-
installer.post_install_messages.each do |name, message|
60-
Bundler.ui.info "Post-install message from #{name}:\n#{message}"
57+
do_install = -> do
58+
Bundler.settings.temporary(inline: true, no_install: false) do
59+
installer = Bundler::Installer.install(Bundler.root, definition, system: true)
60+
installer.post_install_messages.each do |name, message|
61+
Bundler.ui.info "Post-install message from #{name}:\n#{message}"
62+
end
6163
end
6264
end
65+
66+
if Process.respond_to?(:fork)
67+
_, status = Process.waitpid2(Process.fork(&do_install))
68+
exit(status.exitstatus || status.to_i) unless status.success?
69+
else
70+
do_install.call
71+
end
6372
end
6473

6574
runtime = Bundler::Runtime.new(nil, definition)

0 commit comments

Comments
 (0)