発生したエラー
Deployerで./dep deploy
コマンドでデプロイしようとしたところ、package:discover
のステップでエラーが発生した。
$ ./dep deploy xxxx
In Client.php line 103:
[Deployer\Exception\RuntimeException (1)]
The command "cd .../releases/1/server && /usr/bin/php .../releases/1/server/composer.phar install --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader --no-suggest" failed.
➤ Executing task deploy:vendors
Extracting archiveGenerating optimized autoload files
> post-autoload-dump: Illuminate\Foundation\ComposerScripts::postAutoloadDump
> post-autoload-dump: @php artisan package:discover --ansi
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
事象の確認
デプロイ先サーバ上で、エラーメッセージにあるコマンドを実行したところ、問題が再発した。
コマンド@php artisan package:discover --ansi
で例外が発生している。
$ cd .../releases/1/server
$ ./composer.phar install --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader --no-suggest
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Dependency resolution completed in 0.002 seconds
Analyzed 237 packages to resolve dependencies
Analyzed 779 rules to resolve dependencies
Nothing to install or update
Generating optimized autoload files
> post-autoload-dump: Illuminate\Foundation\ComposerScripts::postAutoloadDump
> post-autoload-dump: @php artisan package:discover --ansi
InvalidArgumentException
Please provide a valid cache path.
at vendor/laravel/framework/src/Illuminate/View/Compilers/Compiler.php:36
32| */
33| public function __construct(Filesystem $files, $cachePath)
34| {
35| if (! $cachePath) {
> 36| throw new InvalidArgumentException('Please provide a valid cache path.');
37| }
38|
39| $this->files = $files;
40| $this->cachePath = $cachePath;
artisanコマンドを直接実行してみると再現する。
$ php artisan package:discover --ansi
InvalidArgumentException
Please provide a valid cache path.
at vendor/laravel/framework/src/Illuminate/View/Compilers/Compiler.php:36
32| */
33| public function __construct(Filesystem $files, $cachePath)
34| {
35| if (! $cachePath) {
> 36| throw new InvalidArgumentException('Please provide a valid cache path.');
37| }
38|
39| $this->files = $files;
40| $this->cachePath = $cachePath;
+21 vendor frames
22 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}()
+5 vendor frames
28 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
原因
Please provide a valid cache path
のメッセージ通りデプロイ先サーバにキャッシュディレクトリのパスがないのが問題だった。
対応
./dep
コマンドの実行に先立って、cacheディレクトリを追加したところ、エラーがなくなった。
$ cd .../releases/1/server
$ mkdir -p storage/framework/cache/data/
$ mkdir -p storage/framework/aop/cache
こちらもおススメ