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 circular require between webdrivers.rb and railtie.rb #233

Merged
merged 1 commit into from
Jun 22, 2022

Conversation

amatsuda
Copy link
Contributor

webdrivers.rb requires webdrivers/railtie.rb,

require 'webdrivers/railtie' if defined?(Rails)

and webdrivers/railtie.rb requires webdrivers.rb.

require 'webdrivers'

This causes warning: loading in progress, circular require considered harmful warning from the Ruby interpreter.

Here's a minimum step to reproduce.

$ ruby -w -rrails -rwebdrivers -ep
<internal:.../rubygems/core_ext/kernel_require.rb>:148: warning: <internal:.../rubygems/core_ext/kernel_require.rb>:148: warning: loading in progress, circular require considered harmful - .../webdrivers-5.0.0/lib/webdrivers.rb
	from <internal:.../rubygems/core_ext/kernel_require.rb>:149:in  `require'
	from <internal:.../rubygems/core_ext/kernel_require.rb>:160:in  `rescue in require'
	from <internal:.../rubygems/core_ext/kernel_require.rb>:160:in  `require'
	from .../webdrivers-5.0.0/lib/webdrivers.rb:7:in  `<top (required)>'
	from <internal:.../rubygems/core_ext/kernel_require.rb>:96:in  `require'
	from <internal:.../rubygems/core_ext/kernel_require.rb>:96:in  `require'
	from .../webdrivers-5.0.0/lib/webdrivers/railtie.rb:3:in  `<top (required)>'
	from <internal:.../rubygems/core_ext/kernel_require.rb>:148:in  `require'
	from <internal:.../rubygems/core_ext/kernel_require.rb>:148:in  `require'

This patch fixes the warning by simply removing the require call in webdrivers/railtie.rb, since there won't be any actual use case where directly requiring webdrivers/railtie.rb without requiring webdrivers.rb (via bundler in most cases).

@kapoorlakshya
Copy link
Collaborator

Thanks for your contribution!

P.S. Test failure is unrelated to your changes.

@kapoorlakshya kapoorlakshya merged commit 14c30e6 into titusfortner:main Jun 22, 2022
@amatsuda amatsuda deleted the circular_require branch June 22, 2022 05:59
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

2 participants