drb requires Ruby version >= 2.7.0. The current ruby version is

Published by Moncef Belyamani on

If you just tried to install Cocoapods on your Mac, most likely with sudo gem install cocoapods or gem install cocoapods --user-install, then you probably got an error saying “drb requires Ruby version >= 2.7.0”:

ERROR:  Error installing cocoapods:
  The last version of drb (>= 0) to support your Ruby & RubyGems was 2.0.6. 
  Try installing it with `gem install drb -v 2.0.6` and then running the current command again
  drb requires Ruby version >= 2.7.0. The current ruby version is

There are a few things going on here that are important to understand:

How Ruby gems work

A gem is a way to package Ruby code so that it can be easily installed on a computer. Some gems, like Cocoapods, act like a plugin that can add functionality to an existing app, such as a React Native or iOS app.

Many gems are also made up of other gems. These are known as dependencies because the main gem depends on them to work. Without those dependencies, the main gem would not work. To see the dependencies of a particular gem, you can look it up on rubygems.org.

For example, here is the rubygems page for Cocoapods. You can see that it has 17 main dependencies, but each of those dependencies might have their own dependencies. So, the total number of gems Cocoapods depends on is a lot more than 17.

In addition to depending on specific versions of other gems, many gems also specify which versions of Ruby they support. From the Cocoapods page on rubygems.org, if you click on the cocoapods-core dependency, and then click on activesupport, you will see in the sidebar on the right that the latest version of activesupport requires Ruby version >= 2.7.0. And if you click on the drb gem that is required by activesupport, you will see that the latest version of drb also requires Ruby version >= 2.7.0.

How gem installation works

When you run gem install without specifying a version, your computer looks up the latest version of the gem by default. Then it starts by trying to install all the dependencies of the main gem you want to install. If a dependency has a minimum required Ruby version, then that gets checked as well.

This is why when you try to install Cocoapods while using Ruby 2.6.10 that came preinstalled on your Mac, it complains that “drb requires Ruby version >= 2.7.0”. drb is one of the many gems that Cocoapods depends on, and the latest version of drb requires Ruby version greater than or equal to 2.7.0.

Why the current Ruby version is 2.6.10

macOS 14.x (Sonoma), macOS 13.x (Ventura), and 12.6.x (Monterey) come preinstalled with Ruby 2.6.10, which is why you can run ruby -v out of the box and get an answer. Similarly, you can run gem install and it won’t complain that the gem command is not found.

However, the version of Ruby that comes preinstalled on a Mac, known as the system Ruby, is not meant to be used for development. If you try to install a gem on a fresh macOS installation with just gem install, such as gem install cocoapods, you will get the error you don’t have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

That’s because the default location where gems would get installed is /Library/Ruby/Gems/2.6.0, but Apple doesn’t give you permission to write to that directory. Unfortunately, you’ll still find bad advice to override Apple’s protection with sudo. Please, never use sudo to install gems, even if you’re not using the system Ruby!

Although the solution to add --user-install is safer (because it installs the gems in ~/.gem/ruby/2.6.0/bin, which you have permissions to write to), it still uses the system Ruby, and it can lead to other issues such as:

For more details, read my article that goes over 5 reasons why you shouldn’t use the system Ruby.

How to properly install Cocoapods on a Mac

In this particular case, the issue is that the system Ruby is too old for the latest version of Cocoapods. One solution would be to use an older version of Cocoapods that works with Ruby 2.6.10, but I wouldn’t recommend that for two reasons:

  • The system Ruby shouldn’t be used to install gems
  • You’re missing out on new features, performance improvements, and security fixes that might not be available in older Cocoapods versions

Note that even if macOS came with Ruby 2.7.0 or higher, you still shouldn’t use the system Ruby to install Cocoapods. Instead, you want to install a separate and newer version of Ruby using a special tool that lets you install multiple versions of Ruby at the same time, and easily switch between them.

These tools are known as version managers, and the most popular ones are asdf, chruby, frum, rbenv, and rvm. Even if you’re using Ruby for the first time, it’s worth your time to learn how to use a Ruby version manager because you will inevitably need one.

Over the past twelve years, I’ve helped hundreds of thousands of people set up Ruby on their Mac.

From clean Macs to the most obscure issues, I’ve seen and fixed it all. And the most reliable solution is to use a version manager, specifically chruby and ruby-install.

There are two ways to set up a proper Ruby development environment on a Mac:

  • Have everything set up for you in 15 minutes or less with a single command
  • Spend an hour or more setting everything up manually

Have everything set up for you in 15 minutes or less with a single command

Ruby on Mac is the easiest, fastest, and most reliable way to set up and maintain a proper Ruby dev environment on a Mac. It also automatically installs all the other development tools you’ll need for Cocoapods, Flutter, React Native, Jekyll, Rails, or any other project the depends on Ruby. It will save you so much time and frustration.

Read more about what makes Ruby on Mac special and how much people love Ruby on Mac.

Spend an hour or more setting everything up manually

If you haven’t yet tried to install Ruby or other development tools on your Mac, you should be able to get up and running with the basics by following my free step-by-step guide for installing Ruby on a Mac.