Laravel storage/bootstrap-cache permission denied in CI
Laravel writes compiled views, cache, and logs under storage/ and bootstrap/cache/. If those directories are missing or not writable by the runner user, bootstrapping throws a permission or "valid cache path" error before any code runs.
What this error means
The app fails to boot with "Please provide a valid cache path." or "failed to open stream: Permission denied" for a path under storage/framework or bootstrap/cache.
UnexpectedValueException
The stream or file "storage/logs/laravel.log" could not be opened
in append mode: Failed to open stream: Permission deniedCommon causes
storage subdirectories are missing
A fresh checkout may not include empty storage/framework/{cache,sessions,views} dirs, so Laravel cannot write compiled output.
Directories are not writable by the CI user
A checked-out tree or container volume owned by another user leaves storage and bootstrap/cache non-writable.
How to fix it
Create and chmod the writable directories
- Ensure the framework subdirectories exist.
- Make storage and bootstrap/cache writable in a setup step.
- Then boot artisan and run tests.
- run: |
mkdir -p storage/framework/{cache,sessions,views} bootstrap/cache
chmod -R 777 storage bootstrap/cacheFix ownership in a containerized runner
When the tree is owned by root but the process runs as another user, chown the writable paths to the runner user.
chown -R "$(id -u):$(id -g)" storage bootstrap/cacheHow to prevent it
- Keep
.gitkeepfiles so storage subdirectories exist after checkout. - chmod storage and bootstrap/cache writable as a setup step.
- Match container user ownership to the runner user.