Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions bundler/lib/bundler/inline.rb

This comment was marked as spam.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Author

Choose a reason for hiding this comment

The 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:

rspec ./spec/runtime/inline_spec.rb:193 # bundler/inline#gemfile installs subdependencies quietly if necessary when the install option is not set, and multiple sources used
rspec ./spec/runtime/inline_spec.rb:218 # bundler/inline#gemfile installs quietly from git if necessary when the install option is not set
rspec ./spec/runtime/inline_spec.rb:323 # bundler/inline#gemfile installs gems with native extensions in later gemfile calls

else
do_install.call
end
end

This comment was marked as spam.


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