composer update
を実行するとこんなエラーが発生
The "https://repo.packagist.org/packages.json" file could not be downloaded: php_network_getaddresses: getaddrinfo failed: Name or service not known
failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known
https://repo.packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
原因調査
何が原因なのかを、composer diag
で調べる
vagrant@localhost repo]$ 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
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version: OK
Composer version: 1.9.1
PHP version: 7.3.12
PHP binary path: /usr/bin/php
Checking pubkeys がFAIL となっていて、composer self-update --update-keys
を促されているので、促されるまま実行。
[vagrant@localhost repo]$ 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 -----):
途中、Snapshot PublicKeyと、Tags PublicKeyを聞かれるので、下記から---BEGIN PUBLIC...
からEND PUBLIC KEY----
までコピーしてそれぞれ張り付ける。
https://composer.github.io/pubkeys.html
再度 composer diag
実行したら、all OK!
composer updateも成功しました。
参考にさせていただきました。
http://laravel.hatenablog.com/entry/2014/08/23/095124
https://teratail.com/questions/188872