9
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

composer installしたらエラー出たので対応した(PHP Fatal error: Class UpdateHelper\ComposerPlugin contains 2 \ methods and must therefore be declared abstract or implement the remaining methods)

Last updated at Posted at 2020-10-30

先に結論

composer1.x系でself-updateしてリトライしよう。

composer self-update --1

別パターン

composer self-update --1

上記コマンドでPHP Fatal error: Class UpdateHelper\ComposerPlugin contains 2エラーになるようだったら、vendorディレクトリが壊れてる可能性あり。
1度、vendorディレクトリを削除してからself-updateを実行後、composer installすると解決するかも。
具体的には下記手順です。

  1. vendorディレクトリ削除
  2. composer self-update --1
  3. composer install

詳細

composer installしてらエラー

環境はphp7.3系

$ php -d allow_url_fopen=1 /usr/bin/composer install
PHP Fatal error:  Class UpdateHelper\ComposerPlugin contains 2 \ methods and must therefore be declared abstract or implement the remaining methods (Composer\Plugin\PluginInterface::deactivate, Composer\Plugin\PluginInterface::uninstall) in /var/www/html/vendor/kylekatarnls/update-helper/src/UpdateHelper/ComposerPlugin.php on line 11

Fatal error: Class UpdateHelper\ComposerPlugin contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Composer\Plugin\PluginInterface::deactivate, Composer\Plugin\PluginInterface::uninstall) in /var/www/html/vendor/kylekatarnls/update-helper/src/UpdateHelper/ComposerPlugin.php on line 11

エラー名でググる。

Class UpdateHelper\ComposerPlugin contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods · Issue #7 · kylekatarnls/update-helper
https://github.com/kylekatarnls/update-helper/issues/7

composer2.x系で直ってる?
試してみる。

composer2.x

Composer 2.0 is now available!
https://blog.packagist.com/composer-2-0-is-now-available/

composer self-update

composer -V
Composer version 2.0.3 2020-10-28 15:50:55

アップデートできた。

再度composer installしても同じエラー

コレジャナイ感。
再度ググってみつけた記事がこれ。

Composer dump-autoload or update results in fatal error on Laravel 5.5 - Stack Overflow
https://stackoverflow.com/questions/61236961/composer-dump-autoload-or-update-results-in-fatal-error-on-laravel-5-5

I just found a solution to this problem. Here it is for those who have the same problem.

I have had to delete the directory located inside my directory then run and after that. kylekatarnls vendor composer update -- prefer-source composer dump-autoload

Now all is working just fine.

(google翻訳)私はちょうどこの問題の解決策を見つけました。ここでは、同じ問題を抱えている人のためのものです。

私は私のディレクトリの中にあるディレクトリを削除しなければならなかったし、実行し、その後. kylekatarnls vendor composer update -- prefer-source composer dump-autoload

今、すべてがうまくいっています。

という事で、vendor 配下のkylekatarnls ディレクトリを退避して再度実行

再々度composer installしてら違うエラー

ダメである。
どうもComposer 2に対応したライブラリに更新する必要あり。
そこまでライブラリを更新しようとは思ってなかったので、composer1.x系に戻してリトライ。

$ php -d allow_url_fopen=1 /usr/bin/composer install
The "symfony/thanks" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - symfony/thanks is locked to version v1.2.4 and an update of this package was not requested.
    - symfony/thanks v1.2.4 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.

You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.
(google翻訳:一部のプラグインと互換性がないように見えるComposer2を使用しています。 プラグインを更新するか、プラグインの問題を報告して、Composer2をサポートするように依頼してください。)

composer1.xにリトライしてOK

Composer 2.0 is now available!
https://blog.packagist.com/composer-2-0-is-now-available/

1系へのダウングレード方法も上記にのってた。

composer self-update --1

# composer -V
Composer version 1.10.16 2020-10-24 09:55:59

これで再度composer installをしたところ、エラー解消した。

参考になれば嬉しい限り。

9
6
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
9
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?