在 docker 下安装 composer-plugin-api 时出错

2022-01-21 00:00:00 php laravel composer-php

In laravel 6 project under docker I switched to one of branches and made git pull for updates made by other developer But I got errors by running composer update :

    - joshbrw/laravel-module-installer v1.0.1 requires composer-plugin-api ^2.0 -> no matching package found.
    - joshbrw/laravel-module-installer v1.0.1 requires composer-plugin-api ^2.0 -> no matching package found.
    - joshbrw/laravel-module-installer v1.0.0 requires composer-plugin-api ^2.0 -> no matching package found.
    - Installation request for joshbrw/laravel-module-installer ^1.0 -> satisfiable by joshbrw/laravel-module-installer[v1.0.0, v1.0.1].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
...

In composer.lock I found

"joshbrw/laravel-module-installer": "^1.0",

and :

"require": {
    "composer-plugin-api": "^2.0",
    "php": "^5.4|7.*"
},

In composer.json I see:

"joshbrw/laravel-module-installer": "^1.0",

  1. I tried to install composer-plugin-api. But I am not sure was it a correct decision ?

    root@f32a029eae89:/app# composer require composer-plugin-api Using version ^1.1 for composer-plugin-api ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 134217736 bytes) in phar:///usr/bin/composer/src/Composer/DependencyResolver/RuleSet.php on line 83

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

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

I check memory:

root@f32a029eae89:/app# php -r "echo ini_get('memory_limit').PHP_EOL;"
1024M
root@f32a029eae89:/app# free
              total        used        free      shared  buff/cache   available
Mem:        8085248     5249464     1238412      159684     1597372     2372452
Swap:       2104476      905984     1198492

  1. Which is valid format for composer require package command with big value of memmory ?

I check composer in docker console :

root@f32a029eae89:/app# composer --version
Composer version 1.10.13 2020-09-09 11:46:34

解决方案

joshbrw/laravel-module-installer v1.0.1 requires composer-plugin-api ^2.0 -> no matching package found.

You need composer 2 to install that package, and you are using composer 1.

If you are using the Composer docker image, you just need to add:

FROM composer:2 as composer

to the appropriate dockerfile. If you are downloading it manually, please make sure you download the appropriate version.

相关文章