Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

sudo gem install cocoapods fails on activesupport

ErrorERROR: Error installing cocoapods:

Short answer

The activesupport error means the Ruby that gem uses is older than the dependency allows, which is the case for the Ruby shipped with macOS. CocoaPods' own guide recommends a newer Ruby. Install CocoaPods with Homebrew, which brings its own Ruby, or use rbenv to install one and run gem again.

  • Applies to macOS, CocoaPods, Homebrew, rbenv
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    See which Ruby gem is using and where it installs.

    which ruby
    ruby -v
    gem environment
  2. 2Match what you see, then jump to its fix

    1. 1which ruby prints /usr/bin/ruby and the error says activesupport requires a newer RubyThe system Ruby on macOS is too old for the dependencyFix
    2. 2Homebrew is not an option on this machine, or other tools need a pinned RubyYou want the gem route on a newer Ruby you manage yourselfFix
    3. 3Errno::EPERM Operation not permitted, or a permission error when writing to the gem directoryThe install is blocked by permissions on the system foldersFix

What does the error look like?

  • ERROR: Error installing cocoapods:
  • activesupport requires Ruby version
  • Errno::EPERM Operation not permitted

Cause 1 of 3

The system Ruby on macOS is too old for the dependency

1Check

The CocoaPods guide says the macOS Ruby works for installation but recommends a newer one.

which ruby && ruby -v

2Fix

Skip gem and install CocoaPods through Homebrew. Its formula depends on Homebrew's own Ruby.

brew install cocoapods

3Verify

pod reports a version.

pod --version
which pod

Confirmed by formulae.brew.sh

Did this fix it?

Cause 2 of 3

You want the gem route on a newer Ruby you manage yourself

1Check

The guide suggests a Ruby version manager such as rbenv or RVM, or a Homebrew Ruby, instead of the system one.

rbenv versions

2Fix

Install rbenv, add a current Ruby, make it the global one, then install the gem. No sudo is needed with a user-owned Ruby. Pick a current Ruby version from the list that rbenv install --list shows.

brew install rbenv
rbenv init
rbenv install --list
rbenv install <version>
rbenv global <version>
gem install cocoapods

3Verify

Open a new terminal; ruby points into rbenv and pod works.

which ruby
pod --version

Confirmed by github.com

Did this fix it?

Cause 3 of 3

The install is blocked by permissions on the system folders

1Check

The guide documents EPERM for system Ruby installs, and a user-level install that needs no sudo.

gem environment home

2Fix

Install to a different bin folder as the guide shows, or install into your home folder.

sudo gem install -n /usr/local/bin cocoapods
# or, without sudo:
gem install --user-install cocoapods
gem which cocoapods

3Verify

The pod executable is found at the path you chose.

pod --version

Confirmed by guides.cocoapods.org

Did this fix it?

How do I stop it coming back?

  • Do not use the macOS system Ruby for development tools.
  • Run pod install as your normal user, never as root.
  • Pin the Ruby version of the project so every machine installs the same gems.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Mobile apps

App record creation fails because you lack permission

You cannot add a new app in App Store Connect as a Developer or limited user

Only the Account Holder, an Admin or an App Manager can create an app record, and Apple blocks it until the Account Holder has signed the latest agreement.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.