Skip to content
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 -I require priority #3124

Merged
2 commits merged into from
Feb 5, 2020
Merged

Fix -I require priority #3124

2 commits merged into from
Feb 5, 2020

Conversation

deivid-rodriguez
Copy link
Member

Description:

If require "a" is run when two folders have been specified in the -I option including a "a.rb" file and a "a.so" file respectively, the ruby spec says that the ".rb" file should always be preferred. However, the logic we added in 6b81076d9 to make the -I option always beat default gems does not respect
this spec, creating a difference from the original ruby-core's require.

Tasks:

  • Describe the problem / feature
  • Write tests
  • Write code to solve the problem
  • Get code review from coworkers / friends

I will abide by the code of conduct.

@deivid-rodriguez deivid-rodriguez changed the title Fix dash i require priority Fix -I require priority Feb 4, 2020
@deivid-rodriguez
Copy link
Member Author

@hsbt In order to reproduce this issue with a test, I had to revert 9325078. I think the issue you were having when running tests inside ruby-core back then could actually be this same issue, so that's why I need to revert it. Could you check this PR against ruby-core?

@bronzdoc bronzdoc requested a review from hsbt February 4, 2020 16:39
@deivid-rodriguez
Copy link
Member Author

This issue was found by the Debian ruby team when trying to package psych for ruby2.7, and this PR should close the related issue they opened to the psych project: ruby/psych#431.

@deivid-rodriguez
Copy link
Member Author

I need to figure out the Windows CI issue, but other than that I think it should be ready.

If `require "a"` is run when two folders have been specified in the -I
option including a "a.rb" file and a "a.so" file respectively, the ruby
spec says that the ".rb" file should always be preferred. However, the
logic we added in 6b81076d9
to make the -I option always beat default gems does not respect this
spec, creating a difference from the original ruby-core's require.

[the ruby spec says]: https://github.com/ruby/spec/blob/d80a6e2b221d4f17a8cadcac75ef950c59cba901/core/kernel/shared/require.rb#L234-L246
@deivid-rodriguez
Copy link
Member Author

Windows CI is passing now too 👍.

Copy link
Member

@hsbt hsbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thanks!

begin
if File.symlink? safe_lp # for backward compatibility
next
Gem.suffixes.each do |s|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I confirmed Gem.suffixes returned ["", ".rb", ".bundle"] on macOS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I had two doubts here:

  • Is the "empty extension" actually needed?
  • Should I explicitly loop first through ".rb", and then through the rest of the extensions, so that we don't depend on the order of Gem.suffixes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of the issues are actually present in the current code, so I'll move this forward for now.

@deivid-rodriguez
Copy link
Member Author

@bundlerbot r=hsbt

ghost pushed a commit that referenced this pull request Feb 5, 2020
3124: Fix -I require priority r=hsbt a=deivid-rodriguez

# Description:

If `require "a"` is run when two folders have been specified in the -I option including a "a.rb" file and a "a.so" file respectively, [the ruby spec says](https://github.com/ruby/spec/blob/d80a6e2b221d4f17a8cadcac75ef950c59cba901/core/kernel/shared/require.rb#L234-L246) that the ".rb" file should always be preferred. However, the logic we added in 6b81076d9 to make the -I option always beat default gems does not respect
this spec, creating a difference from the original ruby-core's require.

# Tasks:

- [x] Describe the problem / feature
- [x] Write tests
- [x] Write code to solve the problem
- [x] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
@ghost
Copy link

ghost commented Feb 5, 2020

Build succeeded

  • install (2.3.8)
  • install (2.4.9)
  • install (2.5.7)
  • install (2.6.5)
  • install (jruby-9.2.9.0)
  • macos (2.4.x)
  • macos (2.5.x)
  • macos (2.6.x)
  • ruby_master
  • ubuntu (2.4.x, bundler)
  • ubuntu (2.4.x, rubygems)
  • ubuntu (2.5.x, bundler)
  • ubuntu (2.5.x, rubygems)
  • ubuntu (2.6.x, bundler)
  • ubuntu (2.6.x, rubygems)
  • ubuntu_bundler_master (2.6.x)
  • ubuntu_lint
  • ubuntu_rvm (2.3.8)
  • ubuntu_rvm (jruby-9.2.9.0)
  • ubuntu_rvm (ruby-head)
  • windows (2.4.x)
  • windows (2.5.x)
  • windows (2.6.x)

@ghost ghost merged commit b394438 into master Feb 5, 2020
@ghost ghost deleted the fix_dash_i_require_priority branch February 5, 2020 16:14
sorah pushed a commit to sorah-rbpkg/ruby that referenced this pull request Oct 29, 2020
Origin: rubygems/rubygems#3124
Author: deivid <deivid.rodriguez@riseup.net>

Gbp-Pq: Name 0006-Fix-priority-order-of-paths-in-I-option.patch
This pull request was closed.
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.

None yet

3 participants