workos-ruby icon indicating copy to clipboard operation
workos-ruby copied to clipboard

Zeitwerk eager-load crashes with "uninitialized constant WorkOS::Inflections" in 7.0.0

Open yaakov-sanders opened this issue 7 months ago • 0 comments

Summary

In workos 7.0.0, any call to Zeitwerk::Loader.eager_load_all crashes with NameError: uninitialized constant WorkOS::Inflections. This breaks Rails production boot when config.eager_load = true and any tooling that globally eager-loads (e.g. Tapioca, Sorbet setup).

Reproduction

gem install workos -v 7.0.0
ruby -rworkos -e 'Zeitwerk::Loader.eager_load_all'

Output:

…/zeitwerk-2.7.5/lib/zeitwerk/cref.rb:62:in 'Module#const_get':
uninitialized constant WorkOS::Inflections (NameError)
    @mod.const_get(@cname, false)

Expected

eager_load_all succeeds.

Actual

It raises because the gem's Zeitwerk loader expects lib/workos/inflections.rb to define WorkOS::Inflections, but the file actually defines a top-level WORKOS_INFLECTIONS constant (which is then passed to loader.inflector.inflect(...)).

Proposed fix

Ignore inflections.rb in the loader setup, right next to the existing errors.rb ignore in lib/workos.rb:

loader.ignore("#{__dir__}/workos/errors.rb")
loader.ignore("#{__dir__}/workos/inflections.rb")  # add this
loader.setup

The file is already loaded explicitly via require_relative "workos/inflections" earlier in lib/workos.rb, so ignoring it in Zeitwerk is the correct pattern.

Environment

  • workos 7.0.0
  • zeitwerk 2.7.5 (latest)
  • Ruby: 4.0.2

yaakov-sanders avatar Apr 23 '26 22:04 yaakov-sanders