Skip to main content

Looking at composer I first wanted to check the current version, which is actioned by running the following command

composer -V

The response I was seeing

Composer version 2.1.5 2021-07-23 10:35:47

 

 

How to update to the latest version of Composer?

Going to the Composer site, today the latest version is 2.5.1.  To update my version to this I need to run

composer self-update

However, if you have the following response

  [Composer\Downloader\FilesystemException]
  Filesystem exception:
  Composer update failed: "/usr/local/bin/composer" could not be written.
  rename(/home/fdrc_drupal_dev/.cache/composer/composer-temp.phar,/usr/local/
  bin/composer): Permission denied

Check the owner permissions that have been set at /usr/local/bin/composer.  If root, then you will need to  run the command as

sudo composer self-update

Subsequent response

Upgrading to version 2.5.1 (stable channel).

Use composer self-update --rollback to return to version 2.1.5

Finally confirming the Composer version using composer -V is giving the response

Composer version 2.5.1 2022-12-22 15:33:54

 

Related articles

Andrew Fletcher28 Jul 2023
Install / uninstall modules and themes using composer
Using Composer to Manage Projects and if required their dependenciesIn this section, we're going to dive into how to use Composer to manage project dependencies. Specifically, we'll cover the following:    Installing and Uninstalling packages    Forcing Composer to install the...