Closed maximevaillancourt closed 1 year ago
This is a very weird error, if all caches are disabled (Bootsnap and Spring) so we can go to root of the matter, we find that the application raises a LoadError
for active_admin.rb
, and its directory is in $LOAD_PATH
. Very odd.
No idea how could this gem be related, the only observation is that without this gem, the error can be reproduced (not consistently, but given a few attempts), and without this gem the error cannot be triggered.
Disclaimer, I just participated in the research, don't have access to the application.
We removed Spring
from all of our projects because it causes more problems than it solves. As of Ruby 2.7 it does not appear to make any visible difference either.
In Semantic Logger v4.13 it replaces most autoload
calls to hard requires
. It may help bootsnap out since most files are no loaded on demand.
Environment
semantic_logger
4.12.0 viarails_semantic_logger
4.11.0Expected Behavior
Loading the Rails environment succeeds when
semantic_logger
gem is used in a Rails app.Actual Behavior
Loading the Rails environment fails intermittently with either
NameError: uninitialized constant <constant>
(when Bootsnap is enabled) orLoadError: cannot such such file -- <file>
(when Bootsnap is disabled). The constants that show up are not related tosemantic_logger
: they're often constants from other gems.I'm currently unable to reproduce the bug reliably. We've seen this bug happen intermittently in GitHub Actions the most (where our CI suite runs on x64-based Ubuntu 22.04 VMs), and only one time locally on an M1-powered MacBook. Removing the
rails_semantic_logger
gem entirely fully preventsNameError
/LoadError
from showing up.Full investigation thread available in this other GitHub issue—the most salient insight is in this comment.
Might also be the root cause of https://github.com/rails/rails/issues/45600.