Maaz Zindani

Loading the index…

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

gem install cocoapods gets no gem from rubygems.org

Your error

ERROR: Could not find a valid gem 'cocoapods' (>= 0) in any repository2 more lines it can show

Fix it fast

Most common cause, 1 of 3

rubygems.org cannot be reached, or the proxy sits under a name RubyGems ignores

Export the proxy under the https name in the same shell, or hand it to gem with --http-proxy, which takes priority over the environment.

Fix
export https_proxy=http://proxy.example.com:8080
gem install cocoapods

# or for one command only
gem install cocoapods --http-proxy http://proxy.example.com:8080
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

gem install cocoapods prints Could not find a valid gem 'cocoapods' (>= 0) when RubyGems got no usable reply from its sources. A following 'here is why' line names a network, proxy or server error from rubygems.org; without that line, the source list lacks rubygems.org. Export https_proxy, retry a 5xx later, or add https://rubygems.org/. RubyGems 3.5 to 4.1.

  • Applies to CocoaPods 1.17.0, RubyGems 3.5 to 4.1, macOS and Linux build machines
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Run the install once more and keep its last lines, then print the gem sources and any proxy variables. A 'here is why' line means cause 1 or 2 below; a bare 'in any repository' ending means cause 3.

Run this first
gem install cocoapods 2>&1 | tail -n 4
gem sources --list
env | grep -i _proxy

Then find the line you see in this list and open its fix:

  1. 1rubygems.org cannot be reached, or the proxy sits under a name RubyGems ignoreshere is why: Unable to download data from https://rubygems.org/ - followed by a connection, name lookup or timeout message
  2. 2The server answered with an HTTP error such as 503The here is why line contains bad response (Bad response in RubyGems 4.1), a reason such as Backend read error and a 5xx status code
  3. 3The gem source list has no rubygems.org entryThe message ends with in any repository and no here is why line, and gem sources --list does not show https://rubygems.org/

What does the error look like?

  • ERROR: Could not find a valid gem 'cocoapods' (>= 0) in any repository
  • ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
  • Unable to download data from https://rubygems.org/ - bad response Backend read error 503

Cause 1 of 3

rubygems.org cannot be reached, or the proxy sits under a name RubyGems ignores

You seehere is why: Unable to download data from https://rubygems.org/ - followed by a connection, name lookup or timeout message

Check

When Could not find a valid gem 'cocoapods' carries a here is why line, RubyGems could not download data from the source, so it never saw the cocoapods entry. On a network that needs a proxy, note how RubyGems picks one: for an https source it reads only https_proxy or HTTPS_PROXY, and if neither is set it connects directly, so a lone HTTP_PROXY export changes nothing.

Check
env | grep -i _proxy
curl -sI https://rubygems.org/ | head -n 1

Fix

Export the proxy under the https name in the same shell, or hand it to gem with --http-proxy, which takes priority over the environment. Then install again.

Fix
export https_proxy=http://proxy.example.com:8080
gem install cocoapods

# or for one command only
gem install cocoapods --http-proxy http://proxy.example.com:8080

Verify

gem reports how many gems it installed, and pod answers with its version.

Verify
pod --version

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 3

The server answered with an HTTP error such as 503

You seeThe here is why line contains bad response (Bad response in RubyGems 4.1), a reason such as Backend read error and a 5xx status code

Check

Here the request reached a server, but the reply was an error. RubyGems copies the reason text and the status code into the message. RFC 9110 defines 503 Service Unavailable as a temporary overload or maintenance that will likely clear after some delay, so nothing on the Mac needs repair. When it only ever appears on one office or CI network, the proxy or mirror on that network is the server that answers.

Check
curl -sI https://rubygems.org/ | head -n 1

Fix

Wait a few minutes and run the same install. If the error stays on one network while rubygems.org loads fine elsewhere, take it to whoever runs that proxy or mirror.

Fix
gem install cocoapods

Verify

curl prints a 200 status line, and the install ends with a count of installed gems.

Verify
curl -sI https://rubygems.org/ | head -n 1

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 3 of 3

The gem source list has no rubygems.org entry

You seeThe message ends with in any repository and no here is why line, and gem sources --list does not show https://rubygems.org/

Check

With no fetch error recorded, every listed source replied, yet none of them offers cocoapods. That is what a list holding only a private gem server, a dead mirror or an old entry looks like. The gem sources help names https://rubygems.org as the recommended source and says to remove sources you do not recognize.

Check
gem sources --list

Fix

Add the official source and remove the entry that should not be there, then install.

Fix
gem sources --add https://rubygems.org/
gem sources --remove https://gems.old-mirror.example.com/
gem install cocoapods

Verify

The list shows https://rubygems.org/, and pod runs.

Verify
gem sources --list
pod --version

Confirmed by guides.rubygems.org

Did this fix it?

How do I stop it coming back?

  • On machines behind a proxy, set https_proxy in the shell profile and in the CI environment, not only HTTP_PROXY.
  • Check gem sources --list when you set up a new Mac or build image, and keep only rubygems.org plus private servers you really use.
  • Pin CocoaPods in the project's Gemfile, as the CocoaPods guide suggests, so a retry installs the same version everywhere.

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?

Next step

Want this handled for good?

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