I upgraded a Laravel project from version 7 to 8. When I attempt to deploy it on App Engine, it fails saying "Please provide a valid cache path":
Updating service [***]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build [***] status: FAILURE
Error type: UNKNOWN
[...]
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
In Compiler.php line 36:
Please provide a valid cache path.
Part of my composer.json:
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi",
"@php artisan vendor:publish --force --tag=livewire:assets --ansi"
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"@php artisan ide-helper:generate",
"@php artisan ide-helper:meta"
],
"post-install-cmd": [
"composer dump-autoload",
"php artisan config:clear",
"php artisan cache:clear",
"php artisan view:clear",
"php artisan cache:clear",
"php artisan optimize:clear"
]
A snippet from app.yaml:
env_variables:
APP_STORAGE: /tmp
VIEW_COMPILED_PATH: /tmp
APP_SERVICES_CACHE: /tmp/services.php
APP_PACKAGES_CACHE: /tmp/packages.php
APP_CONFIG_CACHE: /tmp/config.php
APP_ROUTES_CACHE: /tmp/routes.php
CACHE_DRIVER: database
SESSION_DRIVER: database
I do have /storage/framework/views
folder along with the other standard folders under /storage
as well as bootstrap/cache
.
If I remove this line from composer.json (under "post-autoload-dump"):
"@php artisan vendor:publish --force --tag=livewire:assets --ansi"
I am able to deploy the app but it fails on pages that use Livewire components with the following error:
The /workspace/bootstrap/cache directory must be present and writable. (View: /workspace/resources/views/users/edit.blade.php)
ErrorException
in /workspace/vendor/livewire/livewire/src/LivewireComponentsFinder.php (line 58)
in /workspace/vendor/livewire/livewire/src/CompilerEngine.php -> handleViewException (line 41)
in /workspace/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php -> handleViewException (line 60)
in /workspace/vendor/livewire/livewire/src/LivewireViewCompilerEngine.php -> evaluatePath (line 36)
in /workspace/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php -> evaluatePath (line 61)
in /workspace/vendor/laravel/framework/src/Illuminate/View/View.php -> get (line 139)
This happens even though I added the following line to bootstrap/app.php
:
$app->useStoragePath(env('APP_STORAGE', base_path() . '/storage'));
following the guide.
Prior to upgrading Laravel, I had no problems deploying the app on App Engine.