82

rails 6.1.7.10

ruby 2.6.6.

Just did a bundle update to 6.1.7.10 from 6.1.7.8 Now running the application I receive 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)

traceback shows:

...   
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)

rails console is unaffected

unable to find why this is now happening in the application

2
  • 2
    Can you show us the /home/cb/work/sb/config/application.rb:3 line? I have require_relative "boot" in my standard rails app, but I don't see boot in your stack trace. Commented Jan 16 at 6:39
  • 1
    the application.rb requires: require_relative 'boot' require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "active_storage/engine" require "action_mailer/railtie" Commented Jan 17 at 0:52

13 Answers 13

105

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

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

Sign up to request clarification or add additional context in comments.

4 Comments

How about rails new ... when there is no Gemfile file?
Well, i uninstall de current version of the gem, gem uninstall concurrent-ruby -v 1.3.5 and installed the version 1.3.4 gem install concurrent-ruby -v 1.3.4. The rails new started to work just fine.
@Zlatov, I do not understand your question, but you can use a not issue affected Rails version, up to 7.1
@vzamanillo The problem is that rails new is installing concurrent-ruby 1.3.5. So the question is how to prevent that.
82

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

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.

2 Comments

This should be the accepted answer.
I am uninitiated on the macOS. For me, this is like going into system32 and making breaking changes to the whole OS. Now THAT is uncomfortable...
51

All the answers helped me with the problem. I did run gem update, and concurrent-ruby was updated to 1.3.5

I did run

gem install concurrent-ruby -v 1.3.4

then

gem uninstall concurrent-ruby -v 1.3.5

Cocoapods come back to the life

2 Comments

That was the issue. Finally solved it. You are day saver!
Worked for me. Thanks!
27

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.

3 Comments

Thank you, was trying to deploy to Heroku yesterday with a simple one line change and had no idea what was happening.
@marcus.salinas Great! We found it out by comparing with the previous build log, which was fine. We were in chaos for half an hour too.
There is no issue in concurrent_ruby, it merely stopped depending on Logger, which exposed a latent bug in Rails v6 & v7. You simply have to require "logger" manually. Pinning concurrent_ruby works, but is a terribly misunderstood solution.
21

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.

4 Comments

Thanks for hint - that is valuable. I am also seeing the problem of not being able to run 'pod repo update' - it also throws error specified in the post. Looking for a solution to fix.
UPD: this helped for fix 'pod repo update' command too in Fastlane.
CocoaPods GitHub issue for reference: github.com/CocoaPods/CocoaPods/issues/12744
Yes, downgrade concurrent-ruby from 1.3.5 to 1.3.4 was helpful for me. Thank you!
16

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).

1 Comment

Note also that logger will stop being a core Ruby library in December of 2025 with the release of Ruby 3.5, so you will need to add gem "logger" to your Gemfile!
11

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.

1 Comment

Actually Adzap aswer works ( require logger in boot.rb)
6

for anyone who use Mac, I solved it by adding require "logger" to the file "/Library/Ruby/Gems/2.6.0/gems/activesupport-6.1.7.10/lib/active_support/logger_thread_safe_level.rb", as below:

# frozen_string_literal: true

require "active_support/concern"
require "logger" # dont need to remove the following requires.
require "active_support/core_ext/module/attribute_accessors"
require "concurrent"
require "fiber"

credit to @jcoleman

1 Comment

Editing the source code of an installed gem isn't a good idea: it’s not persistent, can introduce subtle bugs, and makes your environment harder to reproduce. A better approach would be to either update the gem (the issue might already be fixed), report the bug to the maintainers, or if needed, patch it via an initializer or fork the gem with the fix. Modifying gem files directly should always be a last resort.
1

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.

Comments

0

I have go the same problme solved by

Uninstall all versions first(if more than one) (make sure to update the path /Users/macbook/...)
by running

gem uninstall -i /Users/macbook/.rvm/rubies/ruby-3.1.1/lib/ruby/gems/3.1.0 concurrent-ruby

Then, reinstall the required version:

gem install concurrent-ruby -v 1.3.4

Comments

0

Add below gems in Gemfile:

gem 'logger'
gem 'bootsnap', '~> 1.18', '>= 1.18.3'

also update config/boot.rb

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

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.

This will resolve the issue in most cases. BTW I am using wsl ubuntu.

enter image description here

Comments

-1

you need to update/downgrade ruby please follow these instructions as i had the same issue and fixed by this one

https://dev.to/luizgadao/easy-way-to-change-ruby-version-in-mac-m1-m2-and-m3-16hl

Comments

-6

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

    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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.