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 LoadError in CentOS 8 - 'require_relative' should not be necessar… #2381

Merged
merged 1 commit into from Sep 24, 2020

Conversation

@joergschray
Copy link
Contributor

@joergschray joergschray commented Sep 24, 2020

…y with recent version of rubygems

Description

The pull request fixes compatibility with CentOS 8: Even for manual installs CentOS 8 separates architecture dependent files from independent ones. Therefore the shared library puma_http11.so ends up in a different directory from puma.rb, which results in the require_relative 'puma/puma_http11' to fail.

Replacing require_relative by require does not change the behavior in case puma_http11.so ends up in the same directory. Apart from that I also consider it best practice in a gem to avoid require_relative altogether. Therefore I also replaced the other
require_relative by require.

Steps to reproduce

Executing the following steps inside a centos:8 docker container:

dnf -y module enable ruby:2.6
dnf -y install ruby ruby-devel gcc make redhat-rpm-config
gem install puma -v5.0.0
puma --version

results in

Traceback (most recent call last):
	9: from /usr/local/bin/puma:23:in `<main>'
	8: from /usr/local/bin/puma:23:in `load'
	7: from /usr/local/share/gems/gems/puma-5.0.0/bin/puma:6:in `<top (required)>'
	6: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
	5: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
	4: from /usr/local/share/gems/gems/puma-5.0.0/lib/puma/cli.rb:6:in `<top (required)>'
	3: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
	2: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
	1: from /usr/local/share/gems/gems/puma-5.0.0/lib/puma.rb:13:in `<top (required)>'
/usr/local/share/gems/gems/puma-5.0.0/lib/puma.rb:13:in `require_relative': cannot load such file -- /usr/local/share/gems/gems/puma-5.0.0/lib/puma/puma_http11 (LoadError)

The paths to the relevant files are

  • /usr/local/share/gems/gems/puma-5.0.0/lib/puma.rb
  • /usr/local/lib64/gems/ruby/puma-5.0.0/puma/puma_http11.so

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added an entry to History.md if this PR fixes a bug or adds a feature. If it doesn't need an entry to HISTORY.md, I have added [changelog skip] or [ci skip] to the pull request title.
  • I have added 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.
@nateberkopec nateberkopec changed the title [changelog skip][ci skip] Fix LoadError in CentOS 8 - 'require_relative' should not be necessar… Fix LoadError in CentOS 8 - 'require_relative' should not be necessar… Sep 24, 2020
@nateberkopec
Copy link
Member

@nateberkopec nateberkopec commented Sep 24, 2020

This is a bugfix, so needs a changelog entry. Obviously we don't test on CentOS, but I want to make sure the tests still pass on every other platform anyway.

'require_relative' breaks gem install on CentOS 8 and should not be necessary with recent version of rubygems
@joergschray joergschray force-pushed the tandem-softworks:EL8_compatibility branch from 2cb286a to ed855d9 Sep 24, 2020
@joergschray
Copy link
Contributor Author

@joergschray joergschray commented Sep 24, 2020

Added a changelog entry as requested.

@MSP-Greg
Copy link
Contributor

@MSP-Greg MSP-Greg commented Sep 24, 2020

@joergschray

Interesting.

I also consider it best practice in a gem to avoid require_relative altogether

Sometimes there is a desire to bypass $LOAD_PATH, especially with vendored files.

Re CentOS, is it generally true that an *.rb will be able to be loaded with require_relative?

@joergschray
Copy link
Contributor Author

@joergschray joergschray commented Sep 24, 2020

Pure ruby files could be loaded via require_relative in CentOS.

However in a gem you usually open up your own namespace. So everything starting with puma/ can always be loaded via require. Of course, a monkey patch will break the require, but that is what a monkey patch is supposed to do.

So unless you put files in a foreign namespace, I do not see a need for using require_relative in a gem.

@nateberkopec
Copy link
Member

@nateberkopec nateberkopec commented Sep 24, 2020

Merits of require/require_relative aside, I certainly want CentOS to work. Merging. Thanks for the patch!

@nateberkopec nateberkopec merged commit 93bb1d0 into puma:master Sep 24, 2020
32 of 34 checks passed
32 of 34 checks passed
ubuntu-20.04 2.5
Details
build
Details
build
Details
ubuntu-20.04 2.7
Details
ubuntu-20.04 2.7
Details
ubuntu-20.04 jruby
Details
ubuntu-20.04 head
Details
windows-2019 2.7
Details
ubuntu-18.04 2.2
Details
ubuntu-18.04 2.3
Details
ubuntu-18.04 2.4
Details
ubuntu-18.04 2.5
Details
ubuntu-18.04 2.6
Details
ubuntu-18.04 2.7
Details
ubuntu-18.04 head
Details
ubuntu-18.04 jruby ubuntu-18.04 jruby
Details
ubuntu-18.04 jruby-head ubuntu-18.04 jruby-head
Details
ubuntu-18.04 truffleruby-head
Details
macos-10.15 2.2
Details
macos-10.15 2.3
Details
macos-10.15 2.4
Details
macos-10.15 2.5
Details
macos-10.15 2.6
Details
macos-10.15 2.7
Details
macos-10.15 head
Details
macos-10.15 jruby
Details
macos-10.15 truffleruby-head macos-10.15 truffleruby-head
Details
windows-2019 2.2
Details
windows-2019 2.3
Details
windows-2019 2.4
Details
windows-2019 2.5
Details
windows-2019 2.6
Details
windows-2019 2.7
Details
windows-2019 mingw
Details
@ehelms
Copy link

@ehelms ehelms commented Sep 25, 2020

Thanks for fixing this. I've hit the same testing on CentOS 7 as well so it is a wider deployment issue. A 5.0.1 with this fix would be greatly appreciated.

@nateberkopec
Copy link
Member

@nateberkopec nateberkopec commented Sep 25, 2020

Yeah I want to get a fix in for #2371, then we'll do 5.0.1.

@joergschray joergschray deleted the tandem-softworks:EL8_compatibility branch Sep 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.