[Fixed] Error installing cocoapods: drb requires Ruby version >= 2.7.0. The current ruby version is 2.6.10.210 – Ruby

by
Alexei Petrov
concurrent-ruby react-native rubygems

Quick Fix: For macOS users, consider using brew instead of gem to install Cocoapods. Run the command brew install cocoapods to resolve the issue related to Ruby version compatibility.

The Problem:

When attempting to install Cocoapods, the user encounters an error message indicating that drb requires a Ruby version greater than or equal to 2.7.0, while the current Ruby version is 2.6.10.210. The user is unable to update Ruby to the required version using rvm, resulting in a different error. The user is seeking guidance on resolving this issue to successfully install Cocoapods.

The Solutions:

Solution 1: Using Homebrew to Install Cocoapods

If you’re encountering issues installing Cocoapods using gem install cocoapods on macOS and you can’t update Ruby to version 2.7.0 or later, you can try using Homebrew as an alternative method to install Cocoapods. Here’s how to do it:

  1. Install Homebrew:

    • If Homebrew is not already installed on your system, open Terminal and run the following command:

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

    • Ensure that Homebrew is up-to-date by running the following command:

      brew update
      
  3. Install Cocoapods with Homebrew:

    • Once Homebrew is updated, run the following command to install Cocoapods:

      brew install cocoapods
      
  4. Verify Cocoapods Installation:

    • After the installation is complete, run the following command to verify that Cocoapods is installed correctly:

      pod --version
      

This should output the version of Cocoapods installed on your system.

By using Homebrew to install Cocoapods, you can avoid the Ruby version compatibility issue and proceed with your React Native project setup.

Solution 2: Using rbenv to update Ruby version

If you encounter the error “drb requires Ruby version >= 2.7.0. The current ruby version is 2.6.10.210” while installing CocoaPods, you can follow these steps to update your Ruby version using the rbenv version manager:

  1. Install rbenv:

    • Open Terminal and run the following command to install rbenv using Homebrew (assuming you have Homebrew installed):

      brew install rbenv
      
  2. Add rbenv to your shell profile:

    • Edit your shell profile file (.bash_profile, .zshrc, etc.), which is typically located in your home directory.

    • Add the following lines to the file:

      export PATH="$HOME/.rbenv/bin:$PATH"
      eval "$(rbenv init -)"
      
  3. Restart your Terminal.

  4. Install Ruby 2.7.4:

    • Run the following command to install Ruby version 2.7.4:

      rbenv install 2.7.4
      
    • This will download and install Ruby 2.7.4.

  5. Set Ruby 2.7.4 as the global version:

    • Run the following command to set Ruby 2.7.4 as the global version for your system:

      rbenv global 2.7.4
      
  6. Verify Ruby version:

    • Run the following command to confirm that Ruby 2.7.4 is now the active version:

      ruby -v
      
  7. Reinstall CocoaPods:

    • Finally, try reinstalling CocoaPods using the following command:

      sudo gem install cocoapods
      
    • This should resolve the issue, and you should be able to use CocoaPods without encountering the error message.

Solution 3: Reading the Error Message

The error message itself provides a hint on how to resolve the issue:

Try installing it with `gem install drb -v 2.0.5` and then running the current command again

Follow these steps to install the correct version of drb:

  1. Open a terminal window.
  2. Run the following command to install drb version 2.0.5:
sudo gem install drb -v 2.0.5
  1. Once the installation is complete, try running the command that you were previously running.

This should resolve the issue and allow you to proceed with the installation of Cocoapods.

Solution 4: Install Ruby and Cocoapods using brew

You may also encounter another error –
"error: While executing gem … (Gem::CommandLineError)
Unable to require activesupport, please install it".

To fix this error, run the following command:
“`
sudo gem install activesupport
“`

Q&A

How to install cocoapods if version problem occurs?

Use homebrew to install cocoapods.

How to update to different ruby version?

Use rbenv to update ruby version.

What if the error message itself has the solution?

Take a careful look into the error message for the solution.

Video Explanation:

The following video, titled "Error installing cocoapods: The last version of activesupport | sudo ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

... requires Ruby version = 2.7.0. The current ruby version is 2.6.10.210. sudo gem install activesupport -v 6.1.7.3 sudo gem install cocoapods ...