-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix $LOAD_PATH
in rake and ext_conf builder
#6490
Fix $LOAD_PATH
in rake and ext_conf builder
#6490
Conversation
Hi! Thanks so much! You could've just moved on by upgrading RubyGems, but you fixed the root cause 😍. Could you add a test for this? |
I'd be happy to. The case is so specific that I'm not sure how to write it / where to put it:
@deivid-rodriguez If you can give me some pointer to maybe a similar test case we have currently, I can try come up with a test case. |
I was thinking of something similar to the one added by #4165, but this seems much more specific, indeed. For this kind tricky tests I normally use realworld testing like the commands run in How are you testing that the fix works? Directly editing the RubyGems copy included with Ruby? Anyways, yeah, too hard to get this tested, I think it's fine as is. |
Exactly, I start with a ruby 3.0 container which I used in the reproduction, manually apply the patch to the default rubygems, and confirmed that it fixed the problem. |
This is a ruby-core specific thing, not a RubyGems thing, so I found a little discrepancy. On my laptop:
So it sounds like we want the latter. |
Oh wow. On linux it was the same. Let me update the PR. |
Umm, there is actually two different possibilities: https://github.com/ruby/ruby/blob/5825d7d4a1a53ba84909a01679f4dfab63fa9739/loadpath.c#L25-L27 Depends on whether |
|
@deivid-rodriguez Sorry for lots of back and forth changing the PR. I think now I have the most clean and robust solution: If rubygems' install location is not present in the default |
Can you rebase this from 7e5fbea? Thanks. |
@ntkme Nice, your solution makes sense to me! Should we move this common logic to the base ext builder? |
@deivid-rodriguez Refactored. I also noticed that there is some inconsistency on the usage of Lines 791 to 802 in 06f8526
|
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.
Awesome, thanks for your work!
Looks like merge queue check failed due to flakiness of #6512. Not sure if any action is required. |
I'm merging the PR fixing the flaky failure and then will merge this one. No action needed @ntkme, thanks for your work! |
$LOAD_PATH
in rake and ext_conf builder
Fix $LOAD_PATH in rake and ext_conf builder (cherry picked from commit 653ee82)
To address rubygems/rubygems#6611 via rubygems/rubygems#6490 that has been released as 3.4.9 https://github.com/rubygems/rubygems/blob/master/CHANGELOG.md#349--2023-03-20
Ref: ruby#647 Ref: rubygems/rubygems#6490 Older rubygems are executing `extconf.rb` with a broken `$LOAD_PATH` causing the `json` gem native extension to be loaded with the stdlib version of the `.rb` files. This fails with ``` json/common.rb:82:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError) ``` Since this is just for `extconf.rb` we can probably just accept that extra argument and ignore it. The bug was fixed in rubygems 3.4.9 / 2023-03-20
Ref: ruby#647 Ref: rubygems/rubygems#6490 Older rubygems are executing `extconf.rb` with a broken `$LOAD_PATH` causing the `json` gem native extension to be loaded with the stdlib version of the `.rb` files. This fails with ``` json/common.rb:82:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError) ``` Since this is just for `extconf.rb` we can probably just accept that extra argument and ignore it. The bug was fixed in rubygems 3.4.9 / 2023-03-20
Ref: #647 Ref: rubygems/rubygems#6490 Older rubygems are executing `extconf.rb` with a broken `$LOAD_PATH` causing the `json` gem native extension to be loaded with the stdlib version of the `.rb` files. This fails with ``` json/common.rb:82:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError) ``` Since this is just for `extconf.rb` we can probably just accept that extra argument and ignore it. The bug was fixed in rubygems 3.4.9 / 2023-03-20
Ref: ruby/json#647 Ref: rubygems/rubygems#6490 Older rubygems are executing `extconf.rb` with a broken `$LOAD_PATH` causing the `json` gem native extension to be loaded with the stdlib version of the `.rb` files. This fails with ``` json/common.rb:82:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError) ``` Since this is just for `extconf.rb` we can probably just accept that extra argument and ignore it. The bug was fixed in rubygems 3.4.9 / 2023-03-20 ruby/json@1f5e849fe0
Ref: ruby/json#647 Ref: rubygems/rubygems#6490 Older rubygems are executing `extconf.rb` with a broken `$LOAD_PATH` causing the `json` gem native extension to be loaded with the stdlib version of the `.rb` files. This fails with ``` json/common.rb:82:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError) ``` Since this is just for `extconf.rb` we can probably just accept that extra argument and ignore it. The bug was fixed in rubygems 3.4.9 / 2023-03-20 ruby/json@1f5e849fe0
Ref: ruby/json#647 Ref: rubygems/rubygems#6490 Older rubygems are executing `extconf.rb` with a broken `$LOAD_PATH` causing the `json` gem native extension to be loaded with the stdlib version of the `.rb` files. This fails with ``` json/common.rb:82:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError) ``` Since this is just for `extconf.rb` we can probably just accept that extra argument and ignore it. The bug was fixed in rubygems 3.4.9 / 2023-03-20 ruby/json@1f5e849fe0
What was the end-user or developer problem that led to this PR?
Installing gem with rake based extension which depends on a native gem (e.g. psych) that has more than one copies on the system (one comes default with ruby installation and one user installation) with the system rubygems can fail in a very strange way.
Reproduction: sinatra/sinatra#1911 (comment)
Explanation: sinatra/sinatra#1911 (comment)
What is your fix for the problem, implemented in this PR?
Per previous PR related to this issue: #4165
Removing this flag caused one of the existing tests to be broken: https://github.com/rubygems/rubygems/actions/runs/4433225457/jobs/7778058872
Therefore, this PR removes it conditionally.
Make sure the following tasks are checked