【发布时间】:2021-02-18 16:36:16
【问题描述】:
我将一个 Laravel 项目从版本 7 升级到了 8。当我尝试在 App Engine 上部署它时,它无法显示“请提供有效的缓存路径”:
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.
我的 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"
]
来自 app.yaml 的 sn-p:
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
我确实有/storage/framework/views 文件夹以及/storage 和bootstrap/cache 下的其他标准文件夹。
如果我从 composer.json 中删除这一行(在“post-autoload-dump”下):
"@php artisan vendor:publish --force --tag=livewire:assets --ansi"
我能够部署应用程序,但在使用 Livewire 组件的页面上失败并出现以下错误:
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)
即使我在bootstrap/app.php 中添加了以下行,也会发生这种情况:
$app->useStoragePath(env('APP_STORAGE', base_path() . '/storage'));
关注guide。
在升级 Laravel 之前,我在 App Engine 上部署应用没有问题。
【问题讨论】:
标签: laravel google-app-engine google-cloud-platform laravel-8 laravel-livewire