-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
bundler/inline: re-exec script after installation #7933
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?
Conversation
|
Thanks @byroot! I'd like to hear if @hsbt or @deivid-rodriguez have any concerns before we merge, but this is my personally preferred solution. 👍🏻 |
|
One issue though is that Ruby doesn't really have a way to grab all the script arguments to do a re-exec without loosing anything, as evidenced by the failing tests (they invoke the code with So this approach wouldn't work in some cases. |
|
Shower thoughts: if we can't re-exec, an alternative could be to do the install in a subprocess. If fork is available it's super simple (albeit a bit unorthodox). |
|
It seems "clean re-exec" is moving forward in Ruby (thanks @byroot!). I think we could vendor securerandom to fix the immediate problem for now, and then introduce this re-execution once usage of original flags is available in Ruby, and progressively unvendor gems only needed for |
That would take years. I think doing the install in a subprocess is a more attractive solution short term. |
What if |
I don't think so. If fork isn't available, we can spawn a subprocess, that subprocess doesn't need to have the same flags. We could also just not bother, use fork only when available. |
|
My thought was that if the ruby process using Regarding not bothering with any fallbacks if fork is not available, I guess that would still be an improvement, but then this problem we're trying to solve here still exists on non-fork platforms. |
Is there any Ruby flag that would have an impact on gem installation? |
|
In the case of our tests, I think they may complain because of flags that may affect the Bundler code that is loaded, for example, |
Right, for tests specifically we could simply pass them via That said, IMO just using fork if available should be relatively simple and would solve the problem for the overwhelming majority of users, so I think it would be valuable to ship just that. Worst case on other platform it's installed in the same process and either that cause no problem or either you need to re-run the script. |
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' ```
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' ```
|
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' ```
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' ```
|
Coincidentially I found the same issue yesterday when running |
|
I think @byroot's issue may still need a bit more work. Basically we'd need both #7960 and #7930 because both RubyGems and Bundler load I can also look into what's not working in #7941, but given that it's more complicated than expected and doesn't work in all platforms, I do prefer the |
Alternate: ruby#7930 Fix: ruby#7930 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' ```
f0bdc7c to
f22a296
Compare
Alternate: #7930
Fix: #7930
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
securerandomso if trying to usebundler/inlinewith a gem that have a dependency onsecurerandomthat don't match the default version, the script fails withGem::LoadError.This can be preproduced on Ruby 3.2.x, after making sure to
gem uninstall securerandomso only the default gem remains`, and then running the following script: