How to Fix the "Logger" Error in CocoaPods by Pinning concurrent‑ruby to 1.3.4
When you run npx expo prebuild
for your Expo project, it automatically generates the native iOS and Android directories based on your configuration. During the iOS setup, Expo invokes CocoaPods—a Ruby gem that manages native dependencies—to install and configure the required pods. However, this process can sometimes fail when CocoaPods attempts to set up the iOS part of your project.
Specifically, a bug in concurrent‑ruby
version 1.3.5, which CocoaPods relies on, causes the installation to break with the following error:
uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)
Since the iOS setup depends on CocoaPods (and, by extension, on the concurrent‑ruby
gem), the workaround is to pin concurrent‑ruby
to version 1.3.4. This post will show you, step by step, how to make that adjustment so that your npx expo prebuild
command can run successfully.
Step-by-Step Guide to Pin concurrent‑ruby
Step 1: Create or Update Your Gemfile
For both macOS and Windows users, a Gemfile is simply a text file that tells Ruby’s package manager, Bundler, which libraries (or "gems") your project needs. In this case, we need to ensure that CocoaPods and the correct version of concurrent‑ruby
are installed to avoid the Logger error.
1.1. Ensure Ruby and Bundler Are Installed
For Windows Users:
First, check if Ruby is installed by opening Command Prompt or PowerShell and running:ruby -v
If Ruby isn’t installed, download and install it using RubyInstaller for Windows. Ruby is typically pre-installed on macOS.
For macOS and Windows Users:
Next, check for Bundler by running:bundle --version
If Bundler isn’t installed, install it by running:
gem install bundler
1.2. Create or Update Your Gemfile
In the root directory of your project, create (or open) a file named Gemfile and add the following content:
source 'https://rubygems.org'
gem 'cocoapods', '1.16.2'
gem 'concurrent-ruby', '1.3.4'
This configuration tells Bundler to install CocoaPods version 1.16.2 and to pin concurrent‑ruby
to version 1.3.4, which avoids the bug causing the Logger error.
Step 2: Install the Dependencies with Bundler
Open your terminal, navigate to your project’s root directory, and run:
bundle install
This command resolves the dependencies and creates a Gemfile.lock
file that locks concurrent‑ruby
to version 1.3.4, ensuring that this version is used throughout your project.
Step 3: Run Pod Install Using Bundler
Once the dependencies are installed, you need to run CocoaPods to install your iOS dependencies. If you already have an ios directory, navigate to it in your terminal. If you don't have an ios directory yet, let Expo generate it by running:
npx expo prebuild
After the ios directory is generated, navigate into it:
cd ios
Then, run the following command to install the pods using the pinned gems:
bundle exec pod install --repo-update --ansi
Using bundle exec
ensures that the pod install process uses the gem versions specified in your Gemfile, which should bypass the Logger error and complete the installation process successfully.
Conclusion
By pinning concurrent‑ruby
to version 1.3.4, you avoid the known bug in version 1.3.5 and later, allowing your npx expo prebuild
command to complete successfully. This workaround is a quick and effective way to keep your Expo project moving forward while the upstream fix is pending.
Have you encountered this error? Let me know in the comments if this solution worked for you or if you have any other tips to share!