Skip to content

Conversation

@casperisfine
Copy link

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:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'activesupport', '7.2.0' # depends on securerandom >= 0.3
end

require 'securerandom'

Unless of course fork isn't available.

Alternate: ruby#7930, ruby#7933
Fix: ruby#7930, ruby#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'
```
Comment on lines +73 to +82
# 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!
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

This comment was marked as spam.

else
do_install.call
end
end

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants