-1

My Symfony 4.4 application was buit with Composer 1.x. Now I need to switch to Composer 2. But I'm unable to do the switch, because Symfony CLI uses Composer 1 no matter what.

I've both composer1 and composer2 installed:

# ls -la /usr/local/bin/ | grep composer
-rwxr-xr-x  1 root root  2354438 dic 31 18:06 composer
-rwxr-xr-x  1 root root  2000535 set 16 16:28 composer1

# /usr/local/bin/composer1 --version
Composer version 1.10.22 2021-04-27 13:10:45

# /usr/local/bin/composer --version
Composer version 2.2.3 2021-12-31 12:18:53

But when I run symfony composer --version, it uses composer 1.x.

Back in '20, Fabien wrote

For Symfony CLI, running symfony composer checks the version of Composer used in the composer.lock file and tries to find a Composer binary named composer1 or composer2.

So the problem is that I need to update the composer.lock of my application to use composer2. Still, I cannot find any reference to the composer versione being used.

So, as per title: how can I update my composer.lock to use Composer 2?

  • 1
    "I need to update the composer.lock of my application to use composer2" - what does that mean? Why not simply use `composer update` to do this? – Nico Haase Jan 05 '22 at 12:22
  • Please read about the advantage of `symfony composer` before downvoting the question, thanks. – Dr. Gianluigi Zane Zanettini Jan 07 '22 at 08:54
  • 1
    Please read about the usage of `symfony composer`. As it relies on checking the lock file from your project, I doubt it can be used to change the Composer version to be used – Nico Haase Jan 07 '22 at 08:56

1 Answers1

0

Ok, I found out by trial and error. It was enough to run

# /bin/php7.4 /usr/local/bin/composer update

(that's the composer2 executable).

Composer worked it's magic and now I get

# symfony composer --version
Composer version 2.2.3 2021-12-31 12:18:53