sudo gem install cocoapods fails on activesupport
ERROR: 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.
Fix it fast
1Find out which cause you have
See which Ruby gem is using and where it installs.
which ruby ruby -v gem environment2Match what you see, then jump to its fix
- 1
which 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
Homebrew 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
Errno::EPERM Operation not permitted, or a permission error when writing to the gem directoryThe install is blocked by permissions on the system foldersFix
- 1
What does the error look like?
ERROR: Error installing cocoapods:activesupport requires Ruby versionErrno::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 -v2Fix
Skip gem and install CocoaPods through Homebrew. Its formula depends on Homebrew's own Ruby.
brew install cocoapods3Verify
pod reports a version.
pod --version
which podConfirmed by formulae.brew.sh
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 versions2Fix
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 cocoapods3Verify
Open a new terminal; ruby points into rbenv and pod works.
which ruby
pod --versionConfirmed by github.com
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 home2Fix
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 cocoapods3Verify
The pod executable is found at the path you chose.
pod --versionConfirmed by guides.cocoapods.org
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
pod install says 'You cannot run CocoaPods as root'
[!] You cannot run CocoaPods as root.
CocoaPods has refused to run as root since version 0.32.0, because root-owned files can leave it in a broken state.
3 causes, each with a fixMobile apps
flutter run on iOS or macOS stops with Error running pod install
Warning: CocoaPods not installed. Skipping pod install.
Flutter only reports that pod install failed; the reason is in the lines just above it.
5 causes, each with a fixMobile apps
Cannot change the App Privacy answers in App Store Connect
Publish Your App Privacy Responses?
Only the Account Holder, Admin and App Manager roles can answer the App Privacy questions.
2 causes, each with a fixMobile 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 fixMobile apps
You cannot find the button to pull your app back from review
No 'remove this version from review' message appears on the version page
There is no button called Reject Binary.
3 causes, each with a fixMobile apps
Your Apple Account cannot sign in to App Store Connect
Sign-in to App Store Connect is refused for an account that should have access
App Store Connect does not open to every Apple Account.
3 causes, each with a fix