Skip to content

Autoloading regression between Rails 7.0 and 7.1 #49629

@bradgessler

Description

@bradgessler

Steps to reproduce

Setup the Rails 7.1 project:

git clone git@github.com:bradgessler/rails-7-1-autoloading-regression.git
cd rails-7-1-autoloading-regression.git
bundle
bin/rails server

Then open http://localhost:3000. You should see the error. Refresh the page and you won't see the error.

Now open ./config/environments/development.rb and change config.eager_load

  config.eager_load = true

Reboot the server and you'll see the Zeitwerk error message.

The path for this helper is set at https://github.com/sitepress/sitepress/blob/main/sitepress-rails/lib/sitepress/engine.rb#L29 and it lives in the Rails app at https://github.com/bradgessler/rails-7-1-autoloading-regression/blob/main/app/content/helpers/page_helper.rb

To see the behavior in Rails 7.0, run:

git checkout -b rails-7-1
bundle
bin/rails server

Load the page with the eager_load setting to true, then false, and you'll see that it works.

Expected behavior

I expect for the dev environment is one of the following:

  1. It continues to work, as it does in Rails 7.0
  2. The Zeitwerk autoloading error is displayed immediately in the dev env

Actual behavior

In my dev env, the helper is not initially loaded. When I refresh the page it's loaded.

Video of this behavior at https://objects.bradgessler.com/Screen-Recording-2023-10-13-at-12.09.03-PM.mov

System configuration

Rails version: 7.1.1

Ruby version: 3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions