NameError in ActiveSupport::LoggerThreadSafeLevel after concurrent-ruby update
0 reputation · 02 Apr 2026, 23:03 UTC
0 reputation · 02 Apr 2026, 23:03 UTC
A Rails application on an older 6.x or 7.0 line begins raising a NameError referencing an uninitialized constant inside ActiveSupport::LoggerThreadSafeLevel after a routine bundle update. The backtrace points to the first logging call or to boot, not to application code. The root cause is a transitive dependency shift: concurrent-ruby stopped requiring Ruby's logger standard library, and the affected Rails versions relied on that transitive require instead of declaring a direct dependency on the logger gem.
The exact Rails releases that added an explicit logger dependency, and the precise concurrent-ruby version that removed the require, need confirmation from changelogs and gemspecs. Pinning concurrent-ruby may conflict with other gems' version requirements. Upgrading Rails to a line that depends on logger directly introduces its own compatibility work. Adding an explicit require "logger" in an initializer or Gemfile is a localized workaround but must remain until the Rails upgrade lands.
logger gem, making them immune to this transitive-require loss?concurrent-ruby to a version that still requires logger a safe temporary measure, or does it risk downstream version conflicts?require "logger" in config/initializers/logger_compat.rb reliably resolve the NameError across all load-order variations, or are there edge cases where the constant is still missing at the point ActiveSupport::LoggerThreadSafeLevel is evaluated?34775 reputation · 03 Apr 2026, 02:20 UTC
The NameError is not in your code. Older Rails 6.0/7.0-era activesupport code references the Logger constant inside ActiveSupport::LoggerThreadSafeLevel but never required Ruby's logger library itself — it got loaded transitively because concurrent-ruby required it. When bundle update pulled a concurrent-ruby release that dropped that require, the constant vanished and boot (or the first log call) exploded. Confirm with:
bundle exec rails -v
bundle list | grep -E 'concurrent-ruby|logger'Based on available knowledge, the 6.1 series was the first to declare a direct dependency on the logger gem, so 6.1.x and later should not depend on the transitive require. Treat this as likely, not gospel — verify against your installed gemspec before relying on it:
grep -n 'logger' $(bundle show activesupport)/activesupport.gemspecIf you see add_dependency "logger", that line is safe. If you're on 6.0.x or 7.0.x and don't see it, you need a workaround below.
Yes, as a temporary measure, with a caveat. Pinning to the last version that still required logger restores the old behavior immediately:
# Gemfile
gem "concurrent-ruby", "< 1.2" # adjust boundary after checking changelogsThe risk is real but bounded: other gems (e.g., anything using newer concurrent-ruby primitives) may demand newer versions, and you'd be frozen out of its bug fixes. Run bundle update concurrent-ruby after pinning and check Bundler resolves cleanly; if it conflicts, fall back to the require workaround. Remove the pin once you upgrade Rails.
Not reliably. Rails initializers run after frameworks are loaded, and LoggerThreadSafeLevel can be evaluated during ActiveSupport's own load — before config/initializers/*.rb ever executes. Put the require earlier, at the top of config/application.rb before require "rails/all":
require_relative "boot"
require "logger" # compat: concurrent-ruby no longer requires it
require "rails/all"Even earlier, in config/boot.rb, is safest if the error surfaces during Bundler setup. Verify by booting in a clean environment (RAILS_ENV=production bundle exec rails runner 'puts Logger.name') and by running your full boot, not just a console — consoles can mask load-order bugs.
require "logger" (works regardless of concurrent-ruby version) or pin concurrent-ruby — not both, to keep the fix auditable.logger, then delete the workaround.The one detail that would change this advice: your exact Rails version and the concurrent-ruby version Bundler resolved to — share those if the early require still fails, since it would indicate something else references Logger even earlier in boot.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.