Skip to content
Latchkey

Composer install slow with no dependency cache in CI

Without a persisted Composer cache, every CI run downloads all dist archives again from Packagist and GitHub. This wastes minutes and adds API pressure that can trigger rate-limit 403s. Caching the Composer cache directory on the composer.lock hash makes repeat installs fast.

What this error means

composer install takes minutes each run downloading the same archives, and occasionally hits GitHub rate limits, because no cache is restored between jobs.

Composer
  - Downloading (100%)
  - Installing symfony/console (v7.0.0): Downloading (100%)
  - Installing guzzlehttp/guzzle (7.8.1): Downloading (100%)
  ... every package downloaded again on the next run

Common causes

No cache step persists the Composer directory

The job downloads every dist archive fresh because nothing restores ~/.cache/composer between runs.

The cache key is not tied to the lock

A key that ignores composer.lock either never hits or serves a stale cache, so downloads repeat.

How to fix it

Cache the Composer directory on the lock hash

  1. Add actions/cache for ~/.cache/composer keyed on the composer.lock hash.
  2. Include a restore-key so partial hits still help.
  3. Run composer install --prefer-dist so cached archives are reused.
.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/.cache/composer
    key: composer-${{ hashFiles('composer.lock') }}
    restore-keys: composer-

Or use the ramsey/composer-install action

This action installs dependencies and manages the Composer cache in one step.

.github/workflows/ci.yml
- uses: ramsey/composer-install@v3

How to prevent it

  • Cache ~/.cache/composer keyed on the composer.lock hash.
  • Install with --prefer-dist so cached archives are reused.
  • Authenticate with COMPOSER_AUTH so fewer requests hit rate limits.

Frequently asked questions

What causes "No Composer cache (slow install)"?
The job downloads every dist archive fresh because nothing restores ~/.cache/composer between runs.
How do I fix No Composer cache (slow install)?
Cache the Composer directory on the lock hash

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card