Maaz Zindani

Loading the index…

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

Running pod on a React Native project fails with can't find gem cocoapods

Errorcan't find gem cocoapods (>= 0.a) with executable pod

Short answer

The pod command exists, but the Ruby that is running it has no CocoaPods gem. This happens after a Ruby switch, with a different GEM_HOME, or when CocoaPods was never installed for this project. Check gem list cocoapods, then run bundle install and bundle exec pod install inside the project.

  • Applies to React Native CLI template, Ruby 3.x, CocoaPods 1.x, macOS 26
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask RubyGems whether the Ruby in this terminal has CocoaPods, and which folders it searches.

    which ruby pod
    gem list cocoapods
    gem environment home
    gem environment path
  2. 2Match what you see, then jump to its fix

    1. 1The project folder has a Gemfile and you ran plain pod installThe project uses Bundler but bundle install was never runFix
    2. 2gem list cocoapods prints nothing, but pod worked earlierThe active Ruby changed and the gem lives in another RubyFix
    3. 3gem install --user-install was used, or GEM_HOME is set in one terminal and not anotherThe gem was installed into the user directory and GEM_HOME or PATH does not matchFix

What does the error look like?

  • can't find gem cocoapods (>= 0.a) with executable pod

Cause 1 of 3

The project uses Bundler but bundle install was never run

1Check

The React Native template README says to run bundle install the first time to install CocoaPods itself, and bundle exec pod install after that. Look for the Gemfile in the project root.

ls Gemfile
gem list cocoapods

2Fix

Install the gems from the Gemfile, then run pod through Bundler from the ios folder's parent.

bundle install
cd ios
bundle exec pod install

3Verify

bundle exec pod install finishes and creates the Pods folder.

bundle exec pod --version

Confirmed by github.com

Did this fix it?

Cause 2 of 3

The active Ruby changed and the gem lives in another Ruby

1Check

RubyGems installs into GEM_HOME and searches GEM_PATH. Switching Ruby with rbenv, RVM or Homebrew gives you a different set of gems, so a pod command left on your PATH can no longer find its gem.

ruby -v
gem environment home
gem environment path

2Fix

Install CocoaPods into the Ruby you are using now. CocoaPods advises against the Ruby that ships with macOS and suggests a managed Ruby from RVM, rbenv or Homebrew. For a project that has a Gemfile, prefer bundle install from the first cause.

gem install cocoapods

3Verify

The gem is listed under the active Ruby.

gem list cocoapods
pod --version

Confirmed by guides.cocoapods.org

Did this fix it?

Cause 3 of 3

The gem was installed into the user directory and GEM_HOME or PATH does not match

1Check

RubyGems documents that --user-install puts gems in your home directory instead of GEM_HOME, and that GEM_PATH is the list of folders searched. If the shell that runs pod does not see that folder, the executable cannot find its gem.

gem environment path
gem which cocoapods

2Fix

Use one place for gems. CocoaPods suggests setting GEM_HOME and adding its bin folder to PATH in your shell profile, then installing again.

# ~/.zshrc
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
# then, in a new terminal:
gem install cocoapods

3Verify

A new terminal finds the gem and the executable.

gem list cocoapods
pod --version

Confirmed by guides.rubygems.org

Did this fix it?

How do I stop it coming back?

  • Keep a Gemfile in the project and always run bundle exec pod install, so the CocoaPods version is the same for every machine.
  • Pick one Ruby manager and do not mix it with the macOS system Ruby.
  • After switching Ruby versions, run bundle install again in each project.

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?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

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