-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make sure to require "rubygems"
explicitly
#7139
Conversation
@@ -2,6 +2,8 @@ | |||
|
|||
require "pathname" | |||
|
|||
require "rubygems" unless defined?(Gem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the defined check faster than the library loaded check? I've not often seen a require guarded like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably no significant difference.
I don't follow, AFAIK |
This is same as
Basically I agreed policy for "Bundler doesn't work without RubyGems". But this case happened irb with ruby core test suite. |
And is it known what have changed this is needed? |
It is the test for ruby itself. |
@simi I handle this. I consider to fix |
Would be great, IMHO adding "random" requires in RubyGems is not really addressing the root problem. Anyway I'm not against merging this if needed. |
I don't think this is harmful, and it allows users to easily override a |
I would expect the opposite. If |
It does happen. Ruby core has warned that |
I'm not strongly attached to this patch, but RubyGems is a dependency of Bundler, so I don't see any harm in making sure it's available before using it. |
Require of bundler, you mean? Or are you suggesting we also disallow to require |
I mean there are already various files assuming RubyGems is loaded like here
RubyGems in bundler entrypoint like bundler.rb to prevent need of loading that individually at other places?
|
I think that's fine too, but here also makes sense to me since it's the place where we monkey patch RubyGems, so we'll need this file to be loaded as early as possible, and always, anyways. |
I don't think we should guard it with Keeping requires localized means libs that don't have other dependencies might be loadable separately. |
Yeah, I agree in general but this case is too special 😅. I initially added the require without the guard at rubygems/bundler#7505, and it caused circular require issues, that's why we added the guard at rubygems/bundler#7520. |
That's a long story written in here :) @deivid-rodriguez feel free to merge if you think this is the way to go. But it would be great to find out a way to test this. Is ruby-core test on RubyGems side failing as well? |
Funny. I didn't expect the circular require problem. Hehe |
cde0afa
to
aa2c321
Compare
I rebased this and added a test. |
This is also done in bundler/lib/bundler/rubygems_integration.rb, but bundler/lib/bundler.rb loads this file before it.
aa2c321
to
8840d85
Compare
@deivid-rodriguez Thanks! @pocke make load It's good to merge this. |
What was the end-user or developer problem that led to this PR?
Requiring just bundler with
--disable=gems
, rubygems/deprecate.rb fails becauseGem
is not defined yet.This happened in a CI too.
https://github.com/ruby/ruby/actions/runs/6793669817/job/18468881547?pr=8867#step:8:1049
What is your fix for the problem, implemented in this PR?
Make sure to
require "rubygems"
explicitly in bundler/lib/bundler/rubygems_ext.rb.This is also done in bundler/lib/bundler/rubygems_integration.rb, but bundler/lib/bundler.rb loads this file before it.
Make sure the following tasks are checked