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

Incompatible with Rails 6, private method `require_dependency' called for Kernel:Module #50

Open
alphabt opened this issue May 13, 2019 · 3 comments

Comments

@alphabt
Copy link

alphabt commented May 13, 2019

Looks like require_dependency is biting us against. This time it fails with Rails 6.

$ consistency_fail
Traceback (most recent call last):
	8: from /Users/user/.rbenv/versions/2.6.1/bin/consistency_fail:23:in `<main>'
	7: from /Users/user/.rbenv/versions/2.6.1/bin/consistency_fail:23:in `load'
	6: from /Users/user/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/consistency_fail-0.3.7/bin/consistency_fail:20:in `<top (required)>'
	5: from /Users/user/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/consistency_fail-0.3.7/lib/consistency_fail.rb:11:in `run'
	4: from /Users/user/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/consistency_fail-0.3.7/lib/consistency_fail/models.rb:19:in `preload_all'
	3: from /Users/user/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/consistency_fail-0.3.7/lib/consistency_fail/models.rb:19:in `each'
	2: from /Users/user/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/consistency_fail-0.3.7/lib/consistency_fail/models.rb:21:in `block in preload_all'
	1: from /Users/user/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/consistency_fail-0.3.7/lib/consistency_fail/models.rb:21:in `each'
/Users/user/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/consistency_fail-0.3.7/lib/consistency_fail/models.rb:22:in `block (2 levels) in preload_all': private method `require_dependency' called for Kernel:Module (NoMethodError)
Did you mean?  require_relative

Gemfile

gem 'rails', '~> 6.0.0.rc1'

According to https://weblog.rubyonrails.org/2019/1/18/Rails-6-0-Action-Mailbox-Action-Text-Multiple-DBs-Parallel-Testing/

Finally, you should pay attention to Xavier Noria’s new Zeitwerk code loader for Ruby. It didn’t make the integration cut for beta1, but starting with beta2, it’ll be the new autoloader for Rails. Be prepared to say goodbye to any lingering require or require_dependency calls in your code!

Not sure if Rails 6 switching to Zeitwerk is relevant to solving the use of require_dependency in consistency_fail.

@alphabt alphabt changed the title Incompatible with Rails 6 Incompatible with Rails 6, private method `require_dependency' called for Kernel:Module May 13, 2019
@trptcolin
Copy link
Owner

Ah, yeah moved to private, OK. So maybe we can add a check for Rails version, and if it's 6+, change the require_dependency to require?

@alphabt
Copy link
Author

alphabt commented May 16, 2019

Changing behavior with a version check should be ok. But I'm not sure if require will work since we tried that last time and it caused a regression with enum per #47.

I haven't done much research into what to use for Rails 6 yet. If I do find something I'll definitely share it here.

@trptcolin
Copy link
Owner

Ah, yeah I guess I was making an assumption there based on the "eliminates all known use cases for require_dependency, including STIs" language in this Zeitwerk blog post - but on re-reading I think it might be more complicated, since the advice on the Rails announcement is about dropping the need for both require and require_dependency...

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

No branches or pull requests

2 participants