Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to downgrade or install a specific version of Composer?

I'm getting the following error in a project I'm setting up:

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.

I've started at a new company this week, just trying to get their projects installed and there doesn't seem to be a way to change my composer version on Windows. I'd rather not update all their packages as I'm not familiar with the projects yet and have no clue what kind of implications go into that.

like image 536
Brendan Strong Avatar asked Oct 29 '20 18:10

Brendan Strong


People also ask

How do I downgrade my composer?

To change to version one run the self-update command and pass in the --1 flag. This will change composer to version one and now you can install your dependencies. Once you have installed your dependencies, now you can run the same command and pass in --2 as the flag and this will switch back to composer version 2.

How do I downgrade my composer php version?

First, grab this URL: https://composer.github.io/pubkeys.html . From there, the terminal will prompt you for which key you need to enter. Once done, you should be able to complete the downgrade process.


4 Answers

Assuming a regular composer installation, to rollback to version 1 of composer, you simply execute:

composer self-update --1

When you want to go back to version 2 (which you should, after updating or removing the incompatible plugins):

composer self-update --2

The above will take you to the latest on any of the two major versions.

You can also "update" to a specific version just by passing the version number to self-update:

composer self-update 1.10.12
composer self-update 2.0.7

After performing any self-update, you can specify --rollback to go back to the previously installed version.

composer self-update
composer self-update --rollback

Finally, if you are feeling adventurous, you can update to a pre-release version by executing:

composer self-update --preview
like image 149
yivi Avatar answered Oct 19 '22 20:10

yivi


If you have already installed composer on your system. then paste the below code to downgrade the composer version with a specific version as per your need.

composer self-update 1.10.14

for ubuntu system use the below command

sudo -H composer self-update 1.10.14
like image 31
Pratik Bharodiya Avatar answered Oct 19 '22 19:10

Pratik Bharodiya


Just two commands worked for me. Currently I have composer 2.x.x , I had 1.10.x . First one command will download downgrade version and then second command will rollback to 1.x.x

  1. php composer self-update --1
  2. composer self-update --rollback
like image 6
Amir Khan Avatar answered Oct 19 '22 20:10

Amir Khan


I found a flag in composer installer "--1" and "--2". I'm using this command inside of my Dockerfile:

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --1
like image 6
Sergiu Savva Avatar answered Oct 19 '22 21:10

Sergiu Savva