rouge requires Ruby version >= 2.7. The current ruby version is 188.8.131.52
If you just tried to install Jekyll on your Mac, most likely with
gem install jekyll --user-install or
sudo gem install jekyll, then you probably got an error saying “rouge requires Ruby version >= 2.7”:
ERROR: Error installing jekyll: The last version of rouge (>= 3.0, < 5.0) to support your Ruby & RubyGems was 3.30.0. Try installing it with `gem install rouge -v 3.30.0` and then running the current command again rouge requires Ruby version >= 2.7. The current ruby version is 184.108.40.206.
These types of errors are common when working with Ruby projects, so it’s important to understand the basics below:
- How Ruby gems work
- How gem installation works
- Why the current Ruby version is 2.6.10
- How to properly install Jekyll on a Mac
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 act like a plugin that can add functionality to an existing project, such as a Jekyll site. Other gems, like Jekyll, are bigger and can be run on their own.
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 Jekyll. You can see that it has 15 main dependencies, but each of those dependencies might have their own dependencies. So, the total number of gems Jekyll depends on is a lot more than 15.
In addition to depending on specific versions of other gems, many gems also specify which versions of Ruby they support. If you look at the sidebar on the right of the Jekyll page on rubygems.org, you’ll see that the required Ruby version is at least 2.5.0 for the latest version of Jekyll.
How gem installation works
So, if the latest version of Jekyll works with Ruby 2.5.0, why can’t we install the latest Jekyll with Ruby 2.6.10?
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.
One of the main dependencies of Jekyll is
kramdown depends on
rouge, and the latest version of rouge requires Ruby version greater than or equal to 2.7. This is why when you try to install Jekyll while using Ruby 2.6.10, it complains that “rouge requires Ruby version >= 2.7”.
Why the current Ruby version is 2.6.10
macOS 12.6 and higher come preinstalled with Ruby 2.6.10, which is why you can run
ruby -v out of the box and get an answer. Similary, 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 jekyll, 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:
- “rouge requires Ruby version >= 2.7” that we’re going over here
- gem executables will not run
- Error installing jekyll: Failed to build gem native extension
For more details, read my article that goes over 5 reasons why you shouldn’t use the system Ruby.
How to properly install Jekyll on a Mac
In this particular case, the issue is that the system Ruby is too old for the latest version of Jekyll. One solution would be to use an older version of Jekyll 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 Jekyll versions
Note that even if macOS came with Ruby 2.7 or higher, you still shouldn’t use the system Ruby to install Jekyll. 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 eleven 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
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. The paid versions can automatically detect and fix many common issues, and they will automatically install and configure all the other development tools you’ll need for Jekyll, Rails, Flutter, React Native, Cocoapods, or any other project the depends on Ruby. It will save you so much time and frustration.
When you buy Ruby on Mac today, you’ll be supporting an independent developer and his family. And if you need it for your job or business, you should be able to expense it.
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.