Add zeitwerk:check rake task to you CI system.

Published on February 08, 2024
Written by Daniel Schoppmann

Zeitwerk is the internal code loader for Rails. Rails delegates all autoloading of ruby files to Zeitwerk, which is itself super powerful and highly customizable. By default, Zeitwerk expects your ruby files to have specific filenames, so a class like class VATChecker and a corresponding vat_checker.rb file won't work. While there are easy ways around this, we have sometimes run into this error and there have been times where the production application did not start because of a code loading error that slipped through in dev mode.

Fortunately, there is an easy-to-use zeitwerk:check rake task that you can use to ensure that your Rails application will boot properly in production. This is especially useful if you have renamed some classes with a structure that Zeitwerk does not expect and your test system does not (yet) catch the new files. Or you have an old codebase and want to upgrade to a newer version of Rails. Best to add it to your CI system of choice so you can catch errors like this up front.

bundle exec rails zeitwerk:check
Subscribe to get future articles via the RSS feed .