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

Tapioca::Loader relies on Rails 6+ #239

Closed
bessey opened this issue Feb 25, 2021 · 1 comment · Fixed by #251
Closed

Tapioca::Loader relies on Rails 6+ #239

bessey opened this issue Feb 25, 2021 · 1 comment · Fixed by #251

Comments

@bessey
Copy link

bessey commented Feb 25, 2021

Run Tapioca dsl on a Rails 5.2.4.4 app and you'll get this:

bash-4.4# bundle exec tapioca dsl
Loading Rails application... Creating scope :authorisable_content. Overwriting existing method Objective.authorisable_content.
# ...
bundler: failed to load command: tapioca (/usr/local/bundle/bin/tapioca)
NoMethodError: undefined method `autoloaders' for Rails:Module
Did you mean?  autoloads
               autoload
               autoload?
               autoload_at
  /usr/local/bundle/gems/tapioca-0.4.13/lib/tapioca/loader.rb:112:in `eager_load_rails_app'
# ...

Given your test suite uses Rails 5.2 I was struggling to work out how it wasn't causing issues for you, but it appears to be because its being monkey patched in:


As best I can tell Rails.autoloaders is a Zeitwerk thing, or at least a 6 thing
https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#rails-autoloaders

paracycle added a commit that referenced this issue Mar 9, 2021
`Rails.autoloaders` did not exist in Rails pre-6.0, so we should not
assume that it will be there. We were faking this by defining an
`autoloaders` method on the fake `Rails` module defined in our test
repo, but we really should not be doing that.

Moreover, we were not actually trying to eager load a Rails app in a way
that is compatible with pre-6.0 versions, which this commit aims to add
as well.

Fixes: #239
@paracycle
Copy link
Member

This was released as part of v0.4.16, thanks for reporting the error, and please let us know if this is still not enough to eager-load a Rails 5.2 app.

This was referenced Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment