Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

composer self-update cannot download or replace composer.phar

ErrorSSL certificate problem: unable to get local issuer certificate

Short answer

composer self-update downloads a new composer.phar and replaces the old one, so it fails for three reasons: the file's folder is not writable for your user, the machine's CA bundle cannot verify the download server, or an IPv6 route times out. Run composer diagnose first, then fix the one it points to.

  • Applies to Composer 2.x, PHP 8.3, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Let Composer check its own setup. It tests connections, the CA file and other common problems, and -vvv shows where it looks for the CA file.

    composer diagnose -vvv
  2. 2Match what you see, then jump to its fix

    1. 1composer diagnose is clean, but the update cannot write the file in a system folder such as /usr/local/bin.Your user cannot replace the installed composer.pharFix
    2. 2SSL certificate problem: unable to get local issuer certificate.The CA bundle is out of date or blocked by security softwareFix
    3. 3Operation timed out, often while the same URL works over IPv4.An IPv6 route is broken and the download times outFix

What does the error look like?

  • SSL certificate problem: unable to get local issuer certificate
  • Operation timed out

Cause 1 of 3

Your user cannot replace the installed composer.phar

1Check

For a system-wide installation, the docs say you may have to run the command with root privileges. Find where Composer is installed and who owns it.

which composer
ls -l "$(which composer)"

2Fix

Run the update as the account that owns the installation. Do not make the folder writable for other users: the docs warn that a directory writable by others could be used to plant a malicious composer.phar.

sudo composer self-update

3Verify

Check the version after the update.

composer --version

Confirmed by getcomposer.org

Did this fix it?

Cause 2 of 3

The CA bundle is out of date or blocked by security software

1Check

The troubleshooting page says to check that the root certificate store or CA bundle is up to date, and that diagnose -vvv shows where Composer looks for the CA file.

composer diagnose -vvv

2Fix

Replace the CA file with a current cacert.pem, or update the system CA store. On Windows, try turning off antivirus or firewall software to see whether it interferes.

sudo apt update && sudo apt install --only-upgrade ca-certificates

3Verify

Run the update again.

composer self-update

Confirmed by getcomposer.org

Did this fix it?

Cause 3 of 3

An IPv6 route is broken and the download times out

1Check

The docs advise fixing your IPv6 setup; as a workaround they give an environment variable that forces curl to resolve with IPv4, which works only when Composer uses the curl extension.

COMPOSER_IPRESOLVE=4 composer diagnose

2Fix

Run the update with COMPOSER_IPRESOLVE=4, or on Linux give IPv4 higher priority in gai.conf as the troubleshooting page shows.

COMPOSER_IPRESOLVE=4 composer self-update

3Verify

The update finishes and composer --version shows the new release.

composer --version

Confirmed by getcomposer.org

Did this fix it?

How do I stop it coming back?

  • Run composer self-update on a schedule on build servers, so you do not jump many versions at once.
  • Keep the OS CA certificates updated with your normal system updates.
  • Use composer self-update --rollback if a new release breaks a build; Composer keeps the last version you had installed.

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

Back end

CodeIgniter 4 cannot write its cache files

CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/

CodeIgniter 4's file cache needs a cache directory that the web server can really write to.

2 causes, each with a fix

Back end

CodeIgniter 3 loads the model but the property is undefined

The model name you are loading is the name of a resource that is already being used: user

CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.

2 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.