You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the lib/onoma/models folder that contains classes that are in the Onoma module and not Onoma::Models so, according to the documentation, I tried to use Zeitwerk::Loader#collapse like the documentation suggest it. Neither onoma/models nor */models worked.
Inside the gem and for running the tests, the working solution was to use loader.collapse('lib/onoma/models') (here).
But, when requiring this gem in a small Rails project recently moved to Rails 6 https://gitlab.com/ekylibre/open-nomenclature-org/ i'm greeted with this error: Zeitwerk::NameError: expected file /app/vendor/bundle/ruby/2.7.0/bundler/gems/onoma-001b654dd2a2/lib/onoma/models/document_category.rb to define constant Onoma::Models::DocumentCategory, but didn't
After fiddling for a time with the configuration the working solution was to collapse using: loader.collapse("#{__dir__}/onoma/models")
Can someone confirm this or point me in the right direction if i'm doing sth wrong?
The text was updated successfully, but these errors were encountered:
In general, the README uses __dir__ in the majority of the examples, but in that particular section it uses relative names. Maybe that should be changed.
The collapse method does not know where it is called. All methods in Zeitwerk that receive paths, resolve relative ones against the current working directory at runtime. That works fine if you control the loader and the current working directory, but if your code is going to be moved (as it is the case in a gem), you need to configure an absolute path to not depend on the current working directory at runtime.
I'm moving a small legacy gem to use zeitwerk for loading: https://gitlab.com/ekylibre/onoma
I have the
lib/onoma/models
folder that contains classes that are in theOnoma
module and notOnoma::Models
so, according to the documentation, I tried to useZeitwerk::Loader#collapse
like the documentation suggest it. Neitheronoma/models
nor*/models
worked.Inside the gem and for running the tests, the working solution was to use
loader.collapse('lib/onoma/models')
(here).But, when requiring this gem in a small Rails project recently moved to Rails 6 https://gitlab.com/ekylibre/open-nomenclature-org/ i'm greeted with this error:
Zeitwerk::NameError: expected file /app/vendor/bundle/ruby/2.7.0/bundler/gems/onoma-001b654dd2a2/lib/onoma/models/document_category.rb to define constant Onoma::Models::DocumentCategory, but didn't
After fiddling for a time with the configuration the working solution was to collapse using:
loader.collapse("#{__dir__}/onoma/models")
Can someone confirm this or point me in the right direction if i'm doing sth wrong?
The text was updated successfully, but these errors were encountered: