Updating Composer

I got stuck while updating composer and i’m not exactly sure what would be the correct way to update or remove / reinstall. Thanks in advance!

Ubuntu 22.04, HestiaCP 1.8.11, System PHP Version 8.3.

~$ composer
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Composer/Autoload/AutoloadGenerator.php on line 879

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Composer/Autoload/AutoloadGenerator.php on line 879
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Composer/Autoload/AutoloadGenerator.php on line 884

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Composer/Autoload/AutoloadGenerator.php on line 884
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 48

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 48
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 56

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 56
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer 2.2.6 2022-02-04 17:00:38
chris@host:~$ composer global self-update
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 48

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 48
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 56

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 56

Changed current directory to /home/chris/.config/composer

PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Composer/Autoload/AutoloadGenerator.php on line 879

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Composer/Autoload/AutoloadGenerator.php on line 879
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Composer/Autoload/AutoloadGenerator.php on line 884

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Composer/Autoload/AutoloadGenerator.php on line 884


  Command "self-update" is not defined.

One way could be:
Remove home/{user}/.composer folder and install it again for your user(s)?

v-add-user-composer username (< as root)

Thanks for your response. I did this with one user. When removing .composer and than running your command I don’t get an error but I can’t update composer afterwards… Any other ideas?

What have you tried? (you should have the latest version by now because of the new installation)
Do you have any other legacy composer files outside of the respective user folders? (/usr/…)

This is what I’m getting when I test it with one of my hestiacp users:

~$ composer self-update
You are already using the latest available Composer version 2.7.7 (stable channel).

We usually install it in /home/user/.composer/ folder

~/.composer/composer self-update 

should work

1 Like

Thank you @eris, when I try to update from there i get the same error. Should i manually edit the files or can I uninstall / install composer fully to repair it?
I don’t use it for one of my websites.

chris@host:/home/chrisuser/.composer$ composer self-update
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 48

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 48
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 56

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 56

  Command "self-update" is not defined.

Also composer validate:

composer validate
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 48

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 48
PHP Deprecated:  Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 56

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/share/php/Symfony/Component/Console/Command/DumpCompletionCommand.php on line 56
./composer.json not found.

Yes deleting should be fine we don’t use it for something important.

1 Like

Thanks @eris!

As reference for others: I fixed it by uninstalling and reinstalling like so:

Uninstall composer:

sudo apt remove --purge composer

Download the installer script using PHP:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

Get the latest Composer installer hash and verify the installer script:

HASH="$(curl -sS https://composer.github.io/installer.sig)"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Run the installer:

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Remove the installer:

php -r "unlink('composer-setup.php');"

Verify installation:

composer --version

Update the project dependencies to their latest versions based on the constraints defined in the composer.json file:

composer update

Update Composer itself to the latest version:

composer self-update
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.