turbo-rails: Can't load turbo-rails without Action Cable starting in Rails 7.1.2
I’m not sure whether to report this bug here, or in Rails. Let me know if I should move it.
With today’s release of Rails 7.1.2, it is no longer possible to use turbo-rails without Action Cable. I get the following error when eager loading is enabled:
NameError: uninitialized constant ActionCable (NameError)
class Turbo::StreamsChannel < ActionCable::Channel::Base
^^^^^^
Did you mean? Rational
/Users/mbrictson/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/turbo-rails-1.5.0/app/channels/turbo/streams_channel.rb:34:in `<main>'
This check in the turbo-rails engine is supposed to automatically remove app/channels from the eager-load paths when Action Cable is not present:
However, starting with Rails 7.1.2, this technique apparently no longer works.
There were changes in Rails 7.1.2 regarding auto/eager loading of paths in engines (see https://github.com/rails/rails/pull/49636), so this could be a new bug Rails, or it could mean that turbo-rails needs to be changed to accommodate the new behavior.
Edit: I confirmed that rolling back https://github.com/rails/rails/pull/49636 fixes the problem.
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 9
- Comments: 16 (7 by maintainers)
Commits related to this issue
- Fix actioncable autoload problem The CI test pipeline breaks for Rails 7.1. The eager loading results into a Zeitwerk error in the turbo-rails gem. The current solution is to include actioncable if t... — committed to sascha-karnatz/alchemy_cms by sascha-karnatz 8 months ago
- Fix actioncable autoload problem The CI test pipeline breaks for Rails 7.1. The eager loading results into a Zeitwerk error in the turbo-rails gem. The current solution is to include actioncable if t... — committed to sascha-karnatz/alchemy_cms by sascha-karnatz 8 months ago
- Fix actioncable autoload problem The CI test pipeline breaks for Rails 7.1. The eager loading results into a Zeitwerk error in the turbo-rails gem. The current solution is to include actioncable if t... — committed to sascha-karnatz/alchemy_cms by sascha-karnatz 8 months ago
- Fix actioncable autoload problem The CI test pipeline breaks for Rails 7.1. The eager loading results into a Zeitwerk error in the turbo-rails gem. The current solution is to include actioncable if t... — committed to AlchemyCMS/alchemy_cms by sascha-karnatz 8 months ago
- Require action_cable/engine https://github.com/hotwired/turbo-rails/issues/512#issuecomment-1806575923 — committed to ApprenticeshipStandardsDotOrg/ApprenticeshipStandardsDotOrg by littleforest 8 months ago
- Work around autoloading issue in turbo-rails See https://github.com/hotwired/turbo-rails/issues/512. — committed to mvz/playdate by mvz 7 months ago
- Require action_cable/engine https://github.com/hotwired/turbo-rails/issues/512#issuecomment-1806575923 — committed to ApprenticeshipStandardsDotOrg/ApprenticeshipStandardsDotOrg by littleforest 8 months ago
- Require action_cable/engine https://github.com/hotwired/turbo-rails/issues/512#issuecomment-1806575923 — committed to ApprenticeshipStandardsDotOrg/ApprenticeshipStandardsDotOrg by littleforest 8 months ago
- chore: Require action_cable/engine https://github.com/hotwired/turbo-rails/issues/512#issuecomment-1806575923 — committed to mishina2228/youtube-api-trial by mishina2228 7 months ago
- Upgrade Rails to 7.1.2 (#508) * Upgrade Rails gem to 7.1.2 * Updates to configuration files * Add new migrations * Update turbo-rails dependencies * Require action_cable/engine https://g... — committed to ApprenticeshipStandardsDotOrg/ApprenticeshipStandardsDotOrg by littleforest 7 months ago
- load actioncable turbo-rails (for now) does not work in Rails 7.1 without Action Cable loaded: https://github.com/hotwired/turbo-rails/issues/512 — committed to maii-chgk/rating-ui by razumau 6 months ago
- Temporarily load ActionCable to fix Turbo issue This can be reverted when the following issue is fixed: https://github.com/hotwired/turbo-rails/issues/512 — committed to dennmart/airport_gap by dennmart 6 months ago
- Require action_cable Workaround for https://github.com/hotwired/turbo-rails/issues/512 — committed to cedarcode/mi_carrera by EmilioCristalli 5 months ago
- Rails 7.1 loads turbo which requires actioncable https://github.com/hotwired/turbo-rails/issues/512 — committed to projectblacklight/blacklight_range_limit by jcoyne 5 months ago
- Don't skip action-cable It is required by turbo-rails. See https://github.com/hotwired/turbo-rails/issues/512 — committed to projectblacklight/blacklight_range_limit by jcoyne 5 months ago
- Temporarily load action-cable it is a test dependency of turbo-rails. See https://github.com/hotwired/turbo-rails/issues/512 — committed to projectblacklight/spotlight by jcoyne 4 months ago
- Don't eager load action cable channels Workaround for https://github.com/hotwired/turbo-rails/issues/512 — committed to cedarcode/mi_carrera by EmilioCristalli 4 months ago
- Require ActionCable and ActiveJob to workaround a bug Even if these aren't being used, it turns out that turbo-rails still tries to autoload them in production. See: * https://github.com/hotwired/... — committed to mjbellantoni/greysky by mjbellantoni 3 months ago
- Require ActionCable and ActiveJob to workaround a bug Even if these aren't being used, it turns out that turbo-rails still tries to autoload them in production. See: * https://github.com/hotwired/... — committed to mjbellantoni/greysky by mjbellantoni 3 months ago
Not urgent! Let me know if there is anything I can do to help.
For now, I am working around the issue by loading Action Cable:
@xymbol this is because, by default, Rails enables eager loading in CI test environments, but not local test environments. See
config/environments/test.rb:https://github.com/rails/rails/blob/v7.1.2/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt#L14-L18
ACK. This gem supports Rails 6.0, need to think about a patch that works for both autoloaders.
The root problem here is an inconsistency between the
config.*endpoints for paths that has been there since Rails 3. Thatdeletecall worked by pure chance, it wouldn’t have worked forconfig.autoload_pathsbecause that API is not really designed to support this.In case it helps urgently, in Rails 7.1 you can throw this in an application initializer:
off the top of my head.
It’s near 1 AM over here.
@dorianmariecom totally forgot about this ticket, I’ll write back!