How to Fix Cocoapods Error on Macbook Pro M1
If you're encountering the error message related to Cocoapods on your Macbook Pro M1 after upgrading to Sequoia, you're not alone. Many developers face issues when trying to run Cocoapods due to compatibility problems between the installed Ruby version and certain gems. This article will guide you through understanding why the error occurs and provide step-by-step solutions to fix it. Understanding the Error The error you received: "/opt/homebrew/Cellar/ruby/3.4.3/lib/ruby/3.4.0/psych/class_loader.rb:99:in 'Psych::ClassLoader::Restricted#find': Tried to load unspecified class: Symbol (Psych::DisallowedClass)" usually suggests that the version of Ruby you're using is trying to load a class in a way that is not permitted by the Psych library, which is responsible for handling YAML files in Ruby. Ruby 3.4 introduced stricter security policies for YAML loading, causing some older libraries like Cocoapods to fail. Here, we outline solutions to help resolve these issues and get your Cocoapods working again. Step-by-Step Solutions Step 1: Installing rbenv to Manage Ruby Versions To avoid conflicts with system Ruby, it's best to use a Ruby version manager like rbenv. Here are the steps to install and configure rbenv: Install rbenv via Homebrew: Open your Terminal and run: brew install rbenv Initialize rbenv: After installation, run: rbenv init Follow the instructions prompted in your terminal to add rbenv to your shell configuration file (.bash_profile, .zshrc, etc.). Restart your terminal or run source ~/.bash_profile or source ~/.zshrc (depending on which file you modified). Step 2: Install Compatible Ruby Version Once rbenv is set up, you can now install a version of Ruby that is compatible with Cocoapods. List available Ruby versions: rbenv install -l Look for Ruby version 3.1.x or 3.2.x, as these are generally more compatible with Cocoapods. Install the preferred Ruby version: Replace 3.1.0 with your desired version: rbenv install 3.1.0 Set the installed version as global default: rbenv global 3.1.0 Step 3: Reinstall Cocoapods After installing a compatible Ruby version, you’ll need to reinstall Cocoapods: Reinstall Cocoapods using gem: gem install cocoapods Verify the installation: To check if Cocoapods is working, run: pod --version If it displays the version number, then you're all set! Step 4: Check for Additional Issues If you still encounter issues, consider the following steps: Update Homebrew: Make sure your Homebrew installation is up-to-date by running: brew update Clear the Cocoapods cache: To ensure no corrupted files are causing the issue: pod cache clean --all Frequently Asked Questions 1. What if I still can't get Cocoapods to work? Try to look for any specific error messages after following the above steps. This may give you clues or adjustments you might need. 2. Can I get help from the CocoaPods community? Absolutely! The CocoaPods GitHub repository and their official Slack channel are great places to ask for help from experienced developers. 3. Is it safe to upgrade Ruby or Cocoapods? Make sure to back up your project before making upgrades, and test thoroughly afterwards to confirm compatibility. By following these steps, you should have resolved the issues you are facing with Cocoapods on your Macbook Pro M1 after the Sequoia upgrade. Remember that keeping your development environment consistent and up-to-date is key to avoiding such issues in the future.

If you're encountering the error message related to Cocoapods on your Macbook Pro M1 after upgrading to Sequoia, you're not alone. Many developers face issues when trying to run Cocoapods due to compatibility problems between the installed Ruby version and certain gems. This article will guide you through understanding why the error occurs and provide step-by-step solutions to fix it.
Understanding the Error
The error you received: "/opt/homebrew/Cellar/ruby/3.4.3/lib/ruby/3.4.0/psych/class_loader.rb:99:in 'Psych::ClassLoader::Restricted#find': Tried to load unspecified class: Symbol (Psych::DisallowedClass)" usually suggests that the version of Ruby you're using is trying to load a class in a way that is not permitted by the Psych library, which is responsible for handling YAML files in Ruby.
Ruby 3.4 introduced stricter security policies for YAML loading, causing some older libraries like Cocoapods to fail. Here, we outline solutions to help resolve these issues and get your Cocoapods working again.
Step-by-Step Solutions
Step 1: Installing rbenv to Manage Ruby Versions
To avoid conflicts with system Ruby, it's best to use a Ruby version manager like rbenv. Here are the steps to install and configure rbenv:
-
Install rbenv via Homebrew: Open your Terminal and run:
brew install rbenv
-
Initialize rbenv: After installation, run:
rbenv init
Follow the instructions prompted in your terminal to add
rbenv
to your shell configuration file (.bash_profile, .zshrc, etc.). -
Restart your terminal or run
source ~/.bash_profile
orsource ~/.zshrc
(depending on which file you modified).
Step 2: Install Compatible Ruby Version
Once rbenv
is set up, you can now install a version of Ruby that is compatible with Cocoapods.
-
List available Ruby versions:
rbenv install -l
Look for Ruby version 3.1.x or 3.2.x, as these are generally more compatible with Cocoapods.
-
Install the preferred Ruby version: Replace
3.1.0
with your desired version:rbenv install 3.1.0
-
Set the installed version as global default:
rbenv global 3.1.0
Step 3: Reinstall Cocoapods
After installing a compatible Ruby version, you’ll need to reinstall Cocoapods:
-
Reinstall Cocoapods using gem:
gem install cocoapods
-
Verify the installation: To check if Cocoapods is working, run:
pod --version
If it displays the version number, then you're all set!
Step 4: Check for Additional Issues
If you still encounter issues, consider the following steps:
-
Update Homebrew: Make sure your Homebrew installation is up-to-date by running:
brew update
-
Clear the Cocoapods cache: To ensure no corrupted files are causing the issue:
pod cache clean --all
Frequently Asked Questions
1. What if I still can't get Cocoapods to work?
Try to look for any specific error messages after following the above steps. This may give you clues or adjustments you might need.
2. Can I get help from the CocoaPods community?
Absolutely! The CocoaPods GitHub repository and their official Slack channel are great places to ask for help from experienced developers.
3. Is it safe to upgrade Ruby or Cocoapods?
Make sure to back up your project before making upgrades, and test thoroughly afterwards to confirm compatibility.
By following these steps, you should have resolved the issues you are facing with Cocoapods on your Macbook Pro M1 after the Sequoia upgrade. Remember that keeping your development environment consistent and up-to-date is key to avoiding such issues in the future.