5

I'm trying to install dependencies for an existing Symfony project I'm trying to work on. I looked at this https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file and it says that I should run the update command: php composer.phar update. I did that, but I get the following error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - phpro/grumphp[v0.12.0, ..., v0.12.1] require composer-plugin-api ~1.0 -> found composer-plugin-api[2.1.0] but it does not match the constraint.
    - Root composer.json requires phpro/grumphp ^0.12 -> satisfiable by phpro/grumphp[v0.12.0, v0.12.1].
3
  • Check your composer.json and see if you have composer-plugin-api on it! If you don't have it, then install it using composer require composer-plugin-api and then try again with composer update . Commented Aug 11, 2021 at 22:09
  • @DhiaDjobbi I tried installing composer-plugin-api. At first it says composer.json has been updated, then it says "Loading composer repositories with package information. Updating dependencies (including require-dev)" then it says "Installation failed, reverting ./composer.json to its original content." Commented Aug 12, 2021 at 17:43
  • 1
    @DhiaDjobbi you cannot install composer-plugin-api itself, that is provided by Composer Commented Aug 12, 2021 at 19:53

3 Answers 3

8

Seems to be it needs composer 1. Try delete the vendor folder and downgrade composer with composer self-update --1. Than run composer install or composer update again.

Sign up to request clarification or add additional context in comments.

1 Comment

Command "self-update" is not defined.
0

As a Windows 11 user, The same issue was found with laravel 10. X. X (latest version). Need to update the composer but "Windows 11" and above do not allow commands like "composer self-update". So I downloaded a new composer.exe from the web composer and installed it again(without removing the older one), It'll update automatically and it worked for me.

Comments

-1

require composer-plugin-api ~1.0

That part from the error messages tells you that any of the packages you are using requires the API provided by Composer v1. In some cases, there is only one solution to this problem: downgrade Composer to v1 to use the packages you are currently using. But this is not a long-term solution, as Packagist has deprecated its support for v1. Also, v2 of Composer brings huge performance improvements, so updating brings real benefits :)

In your specific case, phpro/grumphp is requiring the old API. You are using a pretty old version, as the version constraint ^0.12 does only match two versions of that package, which are 0.12.0 (released in September 2017), and 0.12.1 (released in November 2017). Since 0.18.1 (released in May 2020), this package supports both Composer v1 and v2, so updating this package to 0.18.1 or laters helps to resolve your problem without downgrading to Composer v1.

2 Comments

Thanks for helping. I already downgraded the composer. The current version is 1.4.1 But still having trouble
If you have trouble with anything, please open a new question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.