Maaz Zindani

Loading the index…

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

pod install cannot set up the trunk spec source from cdn.cocoapods.org

Your error

Unable to add a source with url `https://cdn.cocoapods.org/` named `trunk`.1 more line it can show

Fix it fast

Most common cause, 1 of 2

The CDN cannot be reached from this machine

Make the CDN reachable from that shell: export the proxy under the https name, or run on a network that allows cdn.cocoapods.org.

Fix
export https_proxy=http://proxy.example.com:8080
pod install
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Unable to add a source with url `https://cdn.cocoapods.org/` named `trunk` means CocoaPods tried to create its trunk spec source and failed. The reason is hidden unless you add --verbose: either the CDN could not be reached, for example through a proxy that is not set, or the repos folder under ~/.cocoapods could not be written. CocoaPods 1.16 to 1.17.

  • Applies to CocoaPods 1.16 and 1.17, cdn.cocoapods.org trunk, macOS and Linux CI runners
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Run the install again with --verbose. Only then does CocoaPods print, in parentheses on the line below the first one, the error that made adding the source fail.

Run this first
pod install --verbose 2>&1 | grep -A3 "Unable to add a source"

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

  1. 1The CDN cannot be reached from this machineThe verbose line reads CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/CocoaPods-version.yml Response: followed by a network message
  2. 2The repos folder cannot be created or writtenThe verbose line reads Could not create '/Users/me/.cocoapods/repos', the CocoaPods repo cache directory, with an Errno::EACCES or similar error

What does the error look like?

  • Unable to add a source with url `https://cdn.cocoapods.org/` named `trunk`.
  • You can try adding it manually in `/Users/me/.cocoapods/repos` or via `pod repo add`.

Cause 1 of 2

The CDN cannot be reached from this machine

You seeThe verbose line reads CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/CocoaPods-version.yml Response: followed by a network message

Check

To add trunk, CocoaPods first downloads CocoaPods-version.yml from the CDN. When that download keeps failing after its retries, adding the source fails and the outer message is all you see. CocoaPods downloads with Typhoeus, a Ruby client built on libcurl, and libcurl takes its proxy from the environment variable named after the URL scheme, so behind a proxy the https_proxy variable has to be set in the shell that runs pod.

Check
curl -sS https://cdn.cocoapods.org/CocoaPods-version.yml
env | grep -i _proxy

Fix

Make the CDN reachable from that shell: export the proxy under the https name, or run on a network that allows cdn.cocoapods.org. Then install again.

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

Verify

curl prints the version file (lines starting with min: and last:), and pod repo list shows a trunk entry.

Verify
curl -sS https://cdn.cocoapods.org/CocoaPods-version.yml
pod repo list

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 2

The repos folder cannot be created or written

You seeThe verbose line reads Could not create '/Users/me/.cocoapods/repos', the CocoaPods repo cache directory, with an Errno::EACCES or similar error

Check

Before it downloads anything, CocoaPods makes a folder for the new source under the repos directory and writes the source URL into it. The repos directory is ~/.cocoapods/repos unless CP_HOME_DIR or CP_REPOS_DIR points elsewhere. If an earlier sudo pod run left ~/.cocoapods owned by root, or the variable points at a read-only CI cache path, that first write fails.

Check
ls -ld ~/.cocoapods ~/.cocoapods/repos
env | grep -E "CP_(HOME|REPOS)_DIR"

Fix

Give the folder back to your user, or point the variable at a writable path, then install again without sudo.

Fix
sudo chown -R "$USER" ~/.cocoapods
pod install

Verify

The trunk folder now exists under the repos directory, with a .url file holding the CDN address.

Verify
cat ~/.cocoapods/repos/trunk/.url

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Set https_proxy in the CI environment of every iOS job that runs behind a proxy, next to the other proxy variables.
  • Never run pod with sudo, so nothing under ~/.cocoapods ends up owned by root.
  • When a CI job sets CP_HOME_DIR or CP_REPOS_DIR to a cache path, check that the job user can write to it.

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.