Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 1 month ago by CosmicVoyager978

Rails 6.1.7.10 Update Triggers uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

I'm running Rails 6.1.7.10 on Ruby 2.6.6 and recently upgraded from Rails 6.1.7.8 using bundle update.

When starting the application, I now encounter the following error:

/home/cb/.gem/ruby/2.6.6/gems/activesupport-6.1.7.10/lib/active_support/logger_thread_safe_level.rb:16:in
`module:LoggerThreadSafeLevel': uninitialized constant
ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)

The traceback is as follows:

RUBY
... 14: from /home/cb/work/sb/config/environment.rb:2:in `<top (required)>': 13: from /home/cb/work/sb/config/environment.rb:2:in `require_relative': 12: from /home/cb/work/sb/config/application.rb:3:in `<top (required)>': 11: from /home/cb/work/sb/config/application.rb:3:in `require': 10: from /home/cb/.gem/ruby/2.6.6/gems/railties-6.1.7.10/lib/rails.rb:7:in `<top (required)>': 9: from /home/cb/.gem/ruby/2.6.6/gems/railties-6.1.7.10/lib/rails.rb:7:in `require': 8: from /home/cb/.gem/ruby/2.6.6/gems/activesupport-6.1.7.10/lib/active_support.rb:29:in `<top (required)>': 7: from /home/cb/.gem/ruby/2.6.6/gems/activesupport-6.1.7.10/lib/active_support.rb:29:in `require': 6: from /home/cb/.gem/ruby/2.6.6/gems/activesupport-6.1.7.10/lib/active_support/logger.rb:3:in `<top (required)>': 5: from /home/cb/.gem/ruby/2.6.6/gems/activesupport-6.1.7.10/lib/active_support/logger.rb:3:in `require': 4: from /home/cb/.gem/ruby/2.6.6/gems/activesupport-6.1.7.10/lib/active_support/logger_silence.rb:5:in `<top (required)>': 3: from /home/cb/.gem/ruby/2.6.6/gems/activesupport-6.1.7.10/lib/active_support/logger_silence.rb:5:in `require': 2: from /home/cb/.gem/ruby/2.6.6/gems/activesupport-6.1.7.10/lib/active_support/logger_thread_safe_level.rb:8:in `<top (required)>': 1: from /home/cb/.gem/ruby/2.6.6/gems/activesupport-6.1.7.10/lib/active_support/logger_thread_safe_level.rb:9:in `<module:ActiveSupport>': /home/cb/.gem/ruby/2.6.6/gems/activesupport-6.1.7.10/lib/active_support/logger_thread_safe_level.rb:16:in `<module:LoggerThreadSafeLevel>': uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)

It’s worth noting that the Rails console appears unaffected. I haven’t identified why this issue now occurs during the full application boot.

I've come across several solutions in the comments and answers, including:

  • Explicitly requiring Ruby’s standard Logger library (e.g., by adding require "logger" in config/application.rb or config/boot.rb)
  • Pinning the concurrent-ruby gem to version 1.3.4
    (or updating Rails to a version where this issue is resolved)

I'm looking for an explanation as to why this error occurs and the best way to resolve it in my case.

30

Comments 0

Answers 10

Views 15.7k

10 Answers

Answer by StackOverflowTychoAI Agent 1 month ago

0

This error is occurring because the updated version of Rails (6.1.7.10) is no longer automatically loading the Ruby standard library’s Logger class in the context where it’s needed. In your case, during boot the constant Logger isn’t available inside ActiveSupport’s LoggerThreadSafeLevel module, which causes the error when Rails references it.

A common fix is to explicitly require the Logger library before any code that might trigger this reference. You can do this by adding the following at the top of your config/application.rb (or an initializer that runs early):

RUBY
require "logger"

This ensures that Ruby knows about the Logger constant before Rails attempts to use it.

Why Rails Console Is Unaffected

The Rails console likely loads different code paths or loads the library in a different order, which is why you don’t see the error there. However, for booting the full application, the explicit require is necessary.

By adding the require statement, you should resolve the uninitialized constant error.

Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?

No comments yet.

Answer by AstralMariner066 1 month ago

0

The concurrent-ruby version updated, that has a dependency with active support gem.

concurrent-ruby's 1.3.5 version just released few hours ago, but I think there is an issue on it.

Downgrading the concurrent-ruby's version to 1.3.4 in the gemfile will fix this.

No comments yet.

Answer by EclipseRanger679 1 month ago

0

concurrent-ruby v1.3.5 has removed the dependency on logger

https://github.com/ruby-concurrency/concurrent-ruby/commit/d7ce956dacd0b772273d39b8ed31a30cff7ecf38

Just block the gem into your gemfile to the previous version

RUBY
gem 'concurrent-ruby', '1.3.4'

or update rails to 7.1, all Rails versions before are affected by this issue because they have a direct dependency on concurrent

enter image description here

https://github.com/rails/rails/issues/54260

No comments yet.

Answer by JovianStargazer774 1 month ago

0

Many of the answers have suggested pinning concurrent_ruby to 1.3.4, but I believe that's misunderstanding the problem. There's no problem in concurrent-ruby, this issue is actually in ActiveSupport 6 (and maybe 7.0), and concurrent-ruby version prior to 1.3.5 masked the issue.

The issue in Rails was fixed in commit 0f5e7a66143.

The solution is to add require "logger" (note that logger is a core Ruby library) to your application/gem/test file prior to loading Rails (or ActiveSupport).

No comments yet.

Answer by OrbitalGuardian787 1 month ago

0

For me (MacOs Ventura 13.1) Adzap's answer worked but without the require "bootsnap/setup" since that wouldn't run.
Simply adding require "logger" to config/boot.rb did the trick.

No comments yet.

Answer by NeptunianVoyager859 1 month ago

0

I’ve found a temporary workaround: add require "logger" before require "rails" at config/application.rb.

However, I believe that locking the version of concurrent-ruby is also a solution.

No comments yet.

Answer by UranianSurveyor275 1 month ago

0

I have fixed the issue by doing the following in my project directory:

  1. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  2. echo >> /Users/zainishfaq/.zprofile

  3. echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/zainishfaq/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"

  4. open .zshrc

  5. Add the following in the zshrc file

    BASH
    export PATH=$HOME/development/flutter/bin:$PATH export PATH=$HOME/.gem/bin:$PATH # Add RVM to PATH for scripting. Make sure this is the last PATH variable change. export PATH="$PATH:$HOME/.rvm/bin" export PATH="/opt/homebrew/bin:$PATH"
  6. rvm get stable

  7. rvm install 3.1.2

No comments yet.

Answer by LunarScientist052 1 month ago

0

If anyone arrives here and is uncomfortable with locking the concurrent-ruby version, you can require logger and leave concurrent-ruby version unlocked. This is primarily an issue for older Rails 7.0 and 6.1.

In config/boot.rb

RUBY
require "bundler/setup" # Set up gems listed in the Gemfile. require "logger" # Fix concurrent-ruby removing logger dependency which Rails itself does not have require "bootsnap/setup" # Speed up boot time by caching expensive operations.

No comments yet.

Answer by NovaPioneer512 1 month ago

0

This appears to have broken the cocoapods integration in our iOS project. As above, running

bundle add concurrent-ruby -v 1.3.4

in the project root resolved the issue.

This might cause issues down the road as cocoapods updates so keep an eye on that and remove this line if/ when that happens.

No comments yet.

Discussion

No comments yet.