composerのよくわからないエラー

Laravelロゴ

composer を使っていたらこんなのが出た。

具体的にはLaravelのSailをインストールしようとしていました。

$ composer require laravel/sail –dev

https://repo.packagist.org could not be fully loaded (The "https://repo.packagist.org/p2/phar-io/manifest.json" file could not be downloaded: SSL: Connection reset by peer
Failed to enable crypto
Failed to open stream: operation failed), package information was loaded from the local cache and may be out of date

環境
Ubuntu 22.04.1 LTS

前提
sudo apt install composer でcomposerのみインストールした状態です。

ちょっと何言ってるかよくわからない。
エラーを調べるにはdiagで調査することができるらしい。早速やってみる。


$ 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
Composer version: 2.2.6
PHP version: 8.1.2
PHP binary path: /usr/bin/php8.1
OpenSSL version: OpenSSL 3.0.2 15 Mar 2022
cURL version: missing, using php streams fallback, which reduces performance
zip: extension not loaded, unzip present, 7-Zip not available

なるほど
cURL がない(なくてもよさそううだけど)
あと、unzip がないっぽい

$ sudo apt install -y curl unzip
$ composer require laravel/sail --dev
中略

Problem 1
- Root composer.json requires laravel/pint ^1.0 -> satisfiable by laravel/pint[v1.0.0, ..., v1.2.0].
- laravel/pint[v1.0.0, ..., v1.2.0] require ext-xml * -> it is missing from your system. Install or enable PHP's xml extension.
Problem 2
- phpunit/phpunit[9.5.10, ..., 9.5.x-dev] require ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
- Root composer.json requires phpunit/phpunit ^9.5.10 -> satisfiable by phpunit/phpunit[9.5.10, ..., 9.5.x-dev].

翻訳
PHP extensionのext-xml と ext-dom がないよ
その後も、インストールと再実行を繰り返して、以下のようなものが必要なようでした

$ sudo apt install -y curl unzip php-curl php-xml

domはxmlに含んでるようなので不要でした。(というかなかった)
大体エラーメッセージでパッケージがないと言われるのでそれをインストールすればOK。
パッケージ名が良くわからないですが、ubuntuの場合はext-のにゃらら ってやつはPHPのエクステンションなのでphp-ほにゃらら みたいな名前でインストールするとうまくいく場合が多いです。
ダメなら、パッケージ名とディストリビューション名+バージョンでググれば何とかなる。

環境依存をなくすためにsail使いたいのに、インストールするのにPHP必要ってのが微妙なところ。

タイトルとURLをコピーしました