【Docker × Laravel8 Jetstream】 *エラー*Jetstreamインストール時のエラー


*目的
Docker × Laravel8 の環境でJetstreamをインストール時にエラーが発生。どのような対策をとったのか忘却録にまとめています。同じエラーの出ている方の参考になれば幸いです。

1) メモリが足りないというエラー

root@4f02df05a7b0:/work# composer require laravel/jetstream

Using version ^2.1 for laravel/jetstream
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

[22-Jan-2021 21:24:37 Asia/Tokyo] PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.

やったこと) 容量を増やすために追記

参考: https://qiita.com/ucan-lab/items/af39b71c6eb304ddf696

php.ini
// コマンドで操作できるそうですが、私は直接書き込みました。
memory_limit = 256M

memory_limit = -1

** ↑ファイルに修正書き加えた時dockerbuildし直してます

docker-compose down
docker-compose up -d --build

2) 容量は増やしたが、Composer で jetstream をインストールできない

root@e0c9300fc452:/work# composer require laravel/jetstream
Using version ^2.1 for laravel/jetstream
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Installation failed, reverting ./composer.json to its original content.


  [Composer\Downloader\TransportException]                                                                                  
  The "https://packagist.org/p/symfony/polyfill-iconv%24eefa799e6ec8b425e65a6cb02164af323385692efc2847688bc204cb09260b33.j  
  son" file could not be downloaded (HTTP/1.1 404 Not Found)                                                                


require [--dev] [--prefer-source] [--prefer-dist] [--fixed] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

やったこと①)composer diagでチェック(どこが悪いか診断するコマンド)

下記のFAILが出ている。
Checking pubkeys: FAIL

root@e0c9300fc452:/work# composer diag
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: FAIL   *** ここでFAILが出ている ***
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version: You are not running the latest stable version, run `composer self-update` to update (1.10.19 => 2.0.8)
Composer version: 1.10.19
PHP version: 7.4.14
PHP binary path: /usr/local/bin/php
OpenSSL version: OpenSSL 1.1.1d  10 Sep 2019

やったこと②) キー(pubkey)の設定し直しを行う。

# composer self-update --update-keys to set them up

参考記事
https://qiita.com/aberyotaro/items/782fd6ccc053e50f2e78
https://teratail.com/questions/188872

root@6c3992698050:/work# composer self-update --update-keys to set them up


  [Symfony\Component\Console\Exception\RuntimeException]       
  Too many arguments, expected arguments "command" "version".  


self-update [-r|--rollback] [--clean-backups] [--no-progress] [--update-keys] [--stable] [--preview] [--snapshot] [--1] [--2] [--set-channel-only] [--] [<version>]
// このコマンドではkeyの設定し直しができない!!
# composer self-update --update-keys to set them up

3) 上記の通り、Too many arguments のエラーが出る。

やったこと) keyの設定を変更するコマンドを変えて再度実行

# composer self-update --update-keys

kyeを入力するための扉が開いた!!

root@6c3992698050:/work# composer self-update --update-keys 

Open https://composer.github.io/pubkeys.html to find the latest keys
Enter Dev / Snapshot Public Key (including lines with -----):

↑↑↑ pubkeyの入力プロンプトがでたので、下記の2つのkeyを入力。

入力内容はこのサイト=> https://composer.github.io/pubkeys.html
怪しそうだけど...
● Dev / Snapshot Public Key
● Tags Public Key

 ** 解決 **

MBP:docker-laravel-handson airidoi$ docker-compose exec app bash
root@6a18b1a6d2ff:/work# composer require laravel/jetstream


Using version ^2.1 for laravel/jetstream
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 9 installs, 0 updates, 0 removals
  - Installing paragonie/constant_time_encoding (v2.4.0): Downloading (100%)         
  - Installing pragmarx/google2fa (8.0.0): Downloading (100%)         
  - Installing dasprid/enum (1.0.3): Downloading (100%)         
  - Installing bacon/bacon-qr-code (2.0.3): Downloading (100%)         
  - Installing laravel/fortify (v1.7.5): Downloading (100%)         
  - Installing jaybizzle/crawler-detect (v1.2.103): Downloading (100%)         
  - Installing mobiledetect/mobiledetectlib (2.8.34): Downloading (100%)         
  - Installing jenssegers/agent (v2.6.4): Downloading (100%)         
  - Installing laravel/jetstream (v2.1.1): Downloading (100%)         
bacon/bacon-qr-code suggests installing ext-imagick (to generate QR code images)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: jenssegers/agent
Discovered Package: laravel/fortify
Discovered Package: laravel/jetstream
Discovered Package: laravel/sail
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
74 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

嬉しい! でもまた今日も夜更かししてしまった...こうやって生活リズムが崩れるんです。

4) 最後に1点疑問

このコマンド実行のあと、15分くらい結果が出るにのかかります。
かかりすぎでは? 何かおかしいのかなと思っているのですが、どうでしょうか。
もしご存知の方いらっしゃったらコメント欄にご記入いただけますととてもとても嬉しいです!

composer require laravel/jetstream