LoginSignup
4
2

More than 3 years have passed since last update.

[Composer] public keys に関するエラー

Posted at

はじめに

この記事はプログラミング初学者による備忘録用の記事であり、また、少しでも他の初学者のお役に立てればと思い書いています。

今回は、テスト実行時に発生したComposerに関するエラー[RuntimeException] The phar signature did not match the file you downloaded, this means your public keys are outdated or that the phar file is corrupt/has been modifiedの解決策をまとめておきたいと思います。

間違いなどがございましたら、ご指摘のほどよろしくお願い致します。

エラー内容

#!/bin/bash -eo pipefail
sudo composer self-update --1
[RuntimeException]                                                                                                                                     
The phar signature did not match the file you downloaded, this means your public keys are outdated or that the phar file is corrupt/has been modified  

self-update [-r|--rollback] [--clean-backups] [--no-progress] [--update-keys] [--stable] [--preview] [--snapshot] [--1] [--2] [--set-channel-only] [--] [<version>]

Exited with code exit status 1
CircleCI received exit code 1

エラー文で、pharの署名がダウンロードしたファイルと一致していないと言われており、これは公開鍵が古いか、pharファイルが壊れているか、修正されていることを意味します。

下記に、解決策をまとめておきます。
手順通りに実行すると解決できると思います。

解決策

①まず初めに、$ composer diagnoseでComposerの状態を調べます

$ composer diagnose

//実行結果
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
Checking composer version: You are not running the latest stable version, run `composer self-update` to update (2.0.8 => 2.1.3)
Composer version: 2.0.8
PHP version: 7.4.14
PHP binary path: /usr/local/Cellar/php@7.4/7.4.14_1/bin/php

実行結果から、Checking pubkeysがFAILとなっていることが判明しました。
Checking pubkeys:FAILの解決策を調べてみると、$ composer self-update --update-keysを実行することで解決できるそうです。


$ composer self-update --update-keysを実行する

$ 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 -----):

実行結果に参照すべきURLが書かれているので、リンク先であるComposer Public Keys / Checksumsに移動すると、ターミナルで入力すべきkeyである、Dev/Snapshot Public KeyTags Public Keyを得ることができます。
後は、得たkeyをターミナルに貼り付けます。

//ページで取得したDev/Snapshot Public KeyとTags Public Keyを順に貼り付けます
Enter Dev / Snapshot Public Key (including lines with -----):-----BEGIN PUBLIC KEY
//略
END PUBLIC KEY-----

//入力後、下記のようにkeyが出力されると入力成功です
Stored key with fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952

//同じようにTags Public Keyも貼り付けます

2つのkeyを貼り付けた後に、もう1度$ composer diagnoseでComposerの状態を見てみると、下記のようにOKと出力され解決したことがわかります。

Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK

おわりに

上記のような手順を踏むと現時点(2021-6-14)では解決できると思います。

参考文献

Composer Public Keys / Checksums

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2