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
Classes or modules in explicit namespaces are not found #35475
Comments
I just checked |
@fxn How about we just set |
Sounds like @rafaelfranca would like to just fix this in bootsnap by disabling the iseq cache for 2.5 👍 |
PR is up Shopify/bootsnap#257 |
Bootsnap 1.4.4 released with the fix. |
I had this problem with
The relevant file is
But if I immediately exit and |
That is very strange:
Could you please throw Rails.autoloaders.log! in |
@fxn, I have added the autoloaders command but am having trouble duplicating exception. I will explore further and come back to you. |
@fxn, I solved the problem, thanks to your suggestion to use
Prior to creating the
The solution in this case was just to delete I have a work flow of creating name spaces after a particular controller became too complex, which means there were quite a few other cases of having an ordinary (non namespaced) helper clashing with the namespace. For some reason everything would normally load OK, but then occasionally an exception would be thrown on one of the these duplicate name clashes. I will refactor these duplicates, unless you can suggest an easier fix. Thank you for your help. |
Having eliminated all helpers with a name starting with The exception occurs at line 556. The file that is causing the exception contains the following:
This occurs intermittently when I start I am not sure if it is related, but I am also having another issue with the loading process. |
The root problem
This is really a bug in the current Ruby 2.5, but I open an issue here for reference.
Ruby 2.6 does not have this problem. The fix was backported to 2.5, so in principle should be fine in some future release.
How it affects Rails 6 Beta 2
When
bootsnap
loads bytecodes from its cache, Ruby 2.5 does not trigger:class
events, but Zeitwerk needs them to be aware of children in explicit namespaces.That means the if you have a namespace defined in a file like
Hotel
here:Zeitwerk won't be aware of the existence of
Hotel::Pricing
and loadingHotel
will err.You can see this problem in a brand new
6.0.0.beta2
app running Ruby 2.5.3:Workarounds
If your application is affected by this you have three options:
Upgrade to Ruby 2.6.
Disable the bytecode cache of
bootsnap
inconfig/boot.rb
this way:Enable classic mode in
config/application.rb
:The text was updated successfully, but these errors were encountered: