Comments (11)
I apologize, I found other problem.
I took a misstake dupricated select autoload path.
I appriciate your comment.
config.autoload_paths += %W(#{config.root}/app/models/)
config.autoload_paths += %W(#{config.root}/app/models/hoge)
from zeitwerk.
The Foo
class is not owned by your project, apparently, but a gem defines it, and your app reopens it.
So this particular class/module cannot be autoloaded/reloaded and Zeitwerk cannot handle it.
To see what you could do, could you please share the example with actual class/module name and give a bit more of context about it? It acts as namespace too? Tell us a bit more please.
from zeitwerk.
Ah, is the gem an engine?
from zeitwerk.
Yes, This is engine.
from zeitwerk.
ex:
# vendor/bundle/ruby/2.5.0/bundler/gems/whose-gem/lib/whose-gem/engine.rb
module WhoseGem
class Engine < ::Rails::Engine
isolate_namespace WhoseGem
end
end
# vendor/bundle/ruby/2.5.0/bundler/gems/whose-gem/app/models/hoge.rb
class Hoge
end
# app/models/hoge.rb
require "#{WhoseGem::Engine.root}/app/models/hoge.rb"
class Hoge
end
from zeitwerk.
The autoload paths of the application take precendence over the autoload paths of engines. That means, Rails is going to consider your foo.rb
first, and disregard the one in the engine as something (not) autoloadable.
I believe the following would work:
# app/models/hoge.rb
load "#{WhoseGem::Engine.root}/app/models/hoge.rb"
class Hoge
end
It is important to use load
, because when Hodge
is reloaded, you want to evaluate the file in the engine again.
Can you try please?
from zeitwerk.
I appreciate your advice.
I try to use load
tomorrow morning!
from zeitwerk.
I try to use load
. but, not load. error is uninitialized constant error
.
Is there likely another problem if not work load?
from zeitwerk.
Probably. Can you reproduce in a minimal application?
from zeitwerk.
I try.
from zeitwerk.
I tried to reproduction, but i cannot.
maybe, exists other problem?
I keep doing reproduce. but you may probably clone this issue.
I appreciate your comment.
mountable enfine gem
https://github.com/cobafan/sample_mountable_engine
minimum-RailsApplication
https://github.com/cobafan/min-app
from zeitwerk.
Related Issues (20)
- Zeitwerk not loading children of struct namespaces HOT 5
- Zeitwerk not autoload the middleware directory HOT 2
- Zeitwerk, omniauth and multiple DBs (connects_to) HOT 9
- (Re-)Loading modules defined as a root namespace HOT 2
- Ruby 3.3.0-rc1 warning issues HOT 3
- Gemfile/gemspec csv HOT 2
- Getting the source location of a constant while loading it HOT 12
- Gem's loader is being setup multiple times HOT 24
- Autoloading not working in rake task HOT 4
- Zeitwerk::NameError on calling Zeitwerk::Loader.eager_load_all HOT 11
- Deprecation message coming from zeitwerk HOT 2
- Reloading of local gems HOT 27
- drb was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0 HOT 3
- Ruby 3.4.0 no longer includes "abbrev" and it suggests zeitwerk to include it HOT 2
- Error when using in Ractor HOT 3
- Namespaced concerns don't load HOT 33
- Zeitwerk::NameError for gem VERSION HOT 8
- Add CHANGELOG.md to gem HOT 3
- `eager_load` clobers previous `eager_load_dir` and `load_file` calls? HOT 6
- In Rails, `app/jobs/seeder/` directory breaks `db:seed` task HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zeitwerk.