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

require to require_relative #2964

Merged
merged 1 commit into from Sep 21, 2022
Merged

Conversation

MSP-Greg
Copy link
Member

Description

Change use of require to require_relative where appropriate.

Closes #2902

Actions macOS runners seem to be having some issues.

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added (or updated) appropriate tests if this PR fixes a bug or adds a feature.
  • My pull request is 100 lines added/removed or less so that it can be easily reviewed.
  • If this PR doesn't need tests (docs change), I added [ci skip] to the title of the PR.
  • If this closes any issues, I have added "Closes #issue" to the PR description or my commit messages.
  • I have updated the documentation accordingly.
  • All new and existing tests passed, including Rubocop.

@MSP-Greg MSP-Greg mentioned this pull request Sep 20, 2022
@MSP-Greg
Copy link
Member Author

Actions has issues earlier. I reran the test workflow's failed jobs. JFYI. passed

autoload :Const, 'puma/const'
autoload :Server, 'puma/server'
autoload :Launcher, 'puma/launcher'
autoload :Const, "#{__dir__}/puma/const"
Copy link
Member

Choose a reason for hiding this comment

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

This feels weird. Is this weird? I've never seen this before.

Copy link
Member Author

Choose a reason for hiding this comment

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

This feels weird. Is this weird? I've never seen this before.

If it's an absolute path, it 'bypasses' the RubyGems resolution. So

autoload :Const, "puma/const" resolved by RubyGems, similar to require
autoload :Const, "#{__dir__}/puma/const" resolved as a path, no RubyGems, similar to require_relative

The Ruby docs for Kernel.autoload show an absolute path, Module.autoload show a 'RubyGems' like path.

I think most code paths that are followed with 'normal' Puma use will see require_relative for all the files autoloaded here, so these are kind of helpers for running single test files. autload only does something if the constant isn't defined...

@nateberkopec nateberkopec merged commit e7ff17d into puma:master Sep 21, 2022
@MSP-Greg MSP-Greg deleted the 00-require-relative branch September 21, 2022 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time to change to require_relative?
2 participants