Composer warns it is proceeding without cache
Cannot create cache directory /home/deploy/.cache/composer/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache.Short answer
Composer tried to create its cache folder, or write to it, and could not, so it runs without a cache. The path comes from COMPOSER_CACHE_DIR or from the Composer home folder. Point COMPOSER_CACHE_DIR at a folder your user can write, or set cache-read-only if the disk is read-only.
Fix it fast
1Find out which cause you have
Read the path in the warning, then see who owns it and whether your user may write to it.
ls -ld ~/.cache/composer ~/.composer 2>&1; id -un2Match what you see, then jump to its fix
- 1
The folder exists, but ls shows an owner that is not you (often root).The cache folder belongs to another user or is not writableFix - 2
The path is inside a read-only layer, and touching a file there fails with Read-only file system.The filesystem is read-only (container, CI or locked-down host)Fix - 3
A one-off script or image build where the cache is never reused.You do not want a cache at all in this runFix
- 1
What does the error look like?
Cannot create cache directory /home/deploy/.cache/composer/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache.See also cache-read-only config if your filesystem is read-only.
Cause 1 of 3
The cache folder belongs to another user or is not writable
1Check
Composer disables the cache when mkdir fails or when the folder is not writable for the current user.
ls -ld ~/.cache/composer; id -un2Fix
Use a cache folder your user owns for this run, or give the folder back to your user.
export COMPOSER_CACHE_DIR="$HOME/.composer-cache"
composer install3Verify
Run Composer again; the warning is gone and the folder fills up.
composer install && ls "$COMPOSER_CACHE_DIR"Confirmed by getcomposer.org
Cause 2 of 3
The filesystem is read-only (container, CI or locked-down host)
1Check
The warning itself names the cause: it points to the cache-read-only setting for read-only filesystems.
touch ~/.cache/composer/.t && echo writable2Fix
Point the cache at a writable temporary folder, or, for an existing cache you only want to read, turn on the documented cache-read-only config option.
export COMPOSER_CACHE_DIR=/tmp/composer-cache
composer install3Verify
Run the install again and confirm the warning no longer appears.
composer install --no-interactionConfirmed by getcomposer.org
Cause 3 of 3
You do not want a cache at all in this run
1Check
The --no-cache option disables the cache folder, the same as setting COMPOSER_CACHE_DIR to /dev/null.
composer --version2Fix
Pass --no-cache so Composer does not look for the folder.
composer install --no-cache3Verify
The install finishes without the warning.
composer install --no-cache --no-interactionConfirmed by getcomposer.org
How do I stop it coming back?
- Do not mix sudo and normal Composer runs in the same project: stick to one user.
- In CI, set COMPOSER_CACHE_DIR to a folder the job owns and cache that folder between runs.
- Use composer clear-cache if an old cache is damaged, rather than deleting folders by hand.
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
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fixBack 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 fixBack 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 fixBack end
CodeIgniter 3 stops with "Your system folder path does not appear to be set correctly"
503 Service Unavailable
CodeIgniter 3's front controller resolves $system_path and then checks that the result is a directory.
3 causes, each with a fix