-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autoloading from subdirectory with same name as ruby file doesn't work #31
Comments
I tested with the following test case: test "autoloads inheriting from parent namespace" do
files = [
["a.rb", "class A; end"],
["a/x.rb", "class A::X < A; end"],
]
with_setup(files) do
assert A::X
end
end It works fine. However since this is an explicit namespace, I think it's likely you are being hit by the ISeq loading not triggering TracePoint callbacks. Can you try disabling bootsnap in |
Sure, see rails/rails#35475 for background and some workarounds. |
Closing here, since Zeitwerk itself is good, and that issue in Rails has it covered. |
@casperisfine Thanks, it indeed works without bootsnap. |
It seems when I use I have these files: app/graphql/types.rb module Types
...
end app/graphql/types/base.rb module Types
class Base
...
end
Without I have Ruby 2.6.1 and Rails 6 beta 3. |
Can you reproduce that in a minimal pure Ruby setup? |
@fxn More information for the case above:
So, the dir with the file appears in the Also logs:
In my case (@bibendi could you check please, too), the failure only occurs only in the debugging context (i.e. within a Pry session after hitting a |
@fxn Well, I found the cause: byebug stops the main execution thread thus making TracePoint no-op:
And that's a bad news( One possible solution is to activate the TracePoint in its own thread (though adding this just to make one specific debugger happy sounds strange). |
I have some stuff with higher priority in Zeitwerk, but will eventually get to this. I’ll try also to understand if this is an issue that should have to be opened in Bootsnap for example implemented a couple of things to comply with edgy but standard Ruby semantics Zeitwerk relies on. Let’s see! |
Hi everyone! If you're still interested I made a fix for byebug + zeitwerk compatibility. deivid-rodriguez/byebug#847 |
Autoloading doesn't seem to work with a file hierarchy like this:
How to reproduce:
Then, trying to access
Book::Bla
does not autoloadapp/models/book/bla.rb
:The text was updated successfully, but these errors were encountered: