-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
bundler/inline: perform installation from a forked child #7941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,12 +54,35 @@ def definition.lock(*); end | |
| definition.validate_runtime! | ||
|
|
||
| if install || definition.missing_specs? | ||
| Bundler.settings.temporary(inline: true, no_install: false) do | ||
| installer = Bundler::Installer.install(Bundler.root, definition, system: true) | ||
| installer.post_install_messages.each do |name, message| | ||
| Bundler.ui.info "Post-install message from #{name}:\n#{message}" | ||
| do_install = -> do | ||
| Bundler.settings.temporary(inline: true, no_install: false) do | ||
| installer = Bundler::Installer.install(Bundler.root, definition, system: true) | ||
| installer.post_install_messages.each do |name, message| | ||
| Bundler.ui.info "Post-install message from #{name}:\n#{message}" | ||
| end | ||
| end | ||
| end | ||
|
|
||
| # When possible we do the install in a subprocess because to install | ||
| # gems we need to require some default gems like `securerandom` etc | ||
| # which may later conflict with the Gemfile requirements. | ||
| if Process.respond_to?(:fork) | ||
| _, status = Process.waitpid2(Process.fork(&do_install)) | ||
| exit(status.exitstatus || status.to_i) unless status.success? | ||
|
|
||
| # If the install succeeded, we need to refresh gem info | ||
| Bundler.reset! | ||
|
|
||
| builder = Bundler::Dsl.new | ||
| builder.instance_eval(&gemfile) | ||
| builder.check_primary_source_safety | ||
|
|
||
| definition = builder.to_definition(nil, true) | ||
| def definition.lock(*); end | ||
| definition.validate_runtime! | ||
|
Comment on lines
+79
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course it's harder than I expected, because since the install is done in a subprocess the parent need to refresh the gem info. I'm super un-familiar with rubygems/bundler do I don't know what the clean way of doing this, but it seems to work except for native gems :/ There is 3 failing specs left I don't know how to fix: |
||
| else | ||
| do_install.call | ||
| end | ||
| end | ||
This comment was marked as spam.
Sorry, something went wrong. |
||
|
|
||
| runtime = Bundler::Runtime.new(nil, definition) | ||
|
|
||
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.