Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

beachcomberdigital's avatar

Unable to deploy after forge upgrade - "Please provide a valid cache path"

I keep getting an error on deploying a project after the recent upgrade to Forge - everything was deploying without issue prior to the updated release of forge.

On each deployment, attempt it hits the following error:

156/156 [============================] 100% Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi In Compiler.php line 75: Please provide a valid cache path. Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1 

I already have the shared paths defined in the deployment configuration - the documentation indicates that the shared paths are processed by the $ACTIVATE_RELEASE() - not sure how to resolve this - any suggestions?

0 likes
1 reply
LaryAI's avatar
Level 58

The error Please provide a valid cache path usually means Laravel can’t find or write to its cache/storage directories during your deployment process. This commonly happens if the storage or one of its subfolders (like storage/framework/cache) does not exist or is not writable when the artisan commands (like package:discover) run during deployment.

Why is this happening after the Forge upgrade?
Forge recently changed the release deployment flow to use atomic (zero-downtime) deployments. In this setup, newly released directories may not yet have the storage symlinked/shared at the moment some deployment scripts run. If your composer install (and thus, artisan package:discover) is running before the shared storage directory is available, you’ll hit this error.

Solution Steps

1. Ensure You're Not Running Composer Scripts Before Storage Is Linked

By default, Forge runs composer install as part of the deployment process. The problem is that the @php artisan package:discover step (triggered as a composer script) is running before $ACTIVATE_RELEASE()—the Forge step that symlinks shared directories like storage and .env.

Fix:
Edit your deployment script in Forge to run composer install after $ACTIVATE_RELEASE(), and not as the default composer post-install script.

Example Deployment Script:

cd /home/forge/{domain}/current

# Run after the release is activated (shared paths are set up):
composer install --no-interaction --prefer-dist --optimize-autoloader

php artisan migrate --force
php artisan cache:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache

Note: Remove "@php artisan package:discover" or similar artisan commands from your composer.json scripts section, as Artisan commands should be run after the storage path is available.

2. Double Check Storage Permissions

Make sure the storage and bootstrap/cache directories are present in your shared paths in Forge and are writable by the web server user (forge or www-data!).

chmod -R ug+rwx storage bootstrap/cache

3. Check Your config:cache and env File

Make sure .env is also in the shared paths (which is default in Forge!), and after the release is activated, all the necessary environment configuration is present.


In Summary

  • Move any composer install steps after $ACTIVATE_RELEASE().
  • Remove any post-install script hooks that call artisan before storage is linked.
  • Double check permissions.

Why is this the real fix?

Deployment scripts must ensure files and paths exist before hitting any framework code that expects them. With Forge's atomic release flow, it's easy to accidentally run artisan when needed shared paths aren't ready. By moving everything after $ACTIVATE_RELEASE(), you guarantee artisan will run successfully.


Let me know if you need more specific steps based on your composer.json or deployment script!

Please or to participate in this conversation.