78

I installed composer while trying to install CakePHP, but the installation was not successful and I want to uninstall composer. I am not finding any way to do this.

For the installation I used the command:

curl -s https://getcomposer.org/installer | php

I am working in Linux.

2
  • What do you mean by "but the installation was not successful"? Would you care for fixing installation? May 22, 2015 at 12:51
  • @TomasVotruba I mean that some components were not installed properly. I would care for fixing it - if I could. But I've struggled with fixing it for a while now so I thought I would just try to install it all over. May 23, 2015 at 9:16

6 Answers 6

111

During the installation you got a message Composer successfully installed to: ... this indicates where Composer was installed. But you might also search for the file composer.phar on your system.

Then simply:

  1. Delete the file composer.phar.
  2. Delete the Cache Folder:
    • Linux: /home/<user>/.composer
    • Windows: C:\Users\<username>\AppData\Roaming\Composer

That's it.

14
  • 2
    just add little extra information that I didn't find the .composer and was unable to reinstall it again. I just did it by deleting the composer folder in C:\Users\myusername\AppData\Roaming and it worked. Apr 22, 2016 at 11:00
  • 2
    just a reminder. If you installed composer from the root account, you have to delete the files from that same account, otherwise you will get the error "permission denied". May 4, 2016 at 23:41
  • 8
    The composer cache folder is sometimes at /home/<user>/.config/composer
    – calvin
    May 31, 2017 at 16:52
  • 1
    Remember that composer can also be install with Homebrew as well. Make sure that it's removed there by running brew unlink composer followed by brew remove composer. And to make sure that you find all Composer-installations, then go to your root (cd /) and run this command: find ./* -name 'composer.phar' and this `find ./* -name 'composer'. That should tell you of all the locations where the Composer-installation can be installed.
    – Zeth
    Aug 5, 2017 at 12:06
  • 2
    Just use the uninstaller located at C:\ProgramData\Composer\bin
    – Adrian P.
    Sep 8, 2017 at 18:10
52

Uninstall composer

To remove just composer package itself from Ubuntu 16.04 (Xenial Xerus) execute on terminal:

sudo apt-get remove composer

Uninstall composer and it's dependent packages

To remove the composer package and any other dependant package which are no longer needed from Ubuntu Xenial.

sudo apt-get remove --auto-remove composer

Purging composer

If you also want to delete configuration and/or data files of composer from Ubuntu Xenial then this will work:

sudo apt-get purge composer

To delete configuration and/or data files of composer and it's dependencies from Ubuntu Xenial then execute:

sudo apt-get purge --auto-remove composer

https://www.howtoinstall.co/en/ubuntu/xenial/composer?action=remove

1
38

Additional information about removing/uninstalling composer

Answers above did not help me, but what did help me is removing:

  1. ~/.cache/composer
  2. ~/.local/share/composer
  3. ~/.config/composer
  4. ~/.composer

Actual directories can be obtained by the composer command:

$ echo home cache-dir data-dir | xargs -n1 composer config --global
~/.config/composer
~/.cache/composer
~/.local/share/composer
2
  • In my case removing the installation file was enough. but in many other scenarios you may need to remove configuration files, cache etc. Generally speaking it is a good idea to remove every file installed, whether you want to reinstall or uninstall a package / program. Thumbs up for the answer. Oct 6, 2017 at 7:27
  • 1
    on debian I don't have those files, and yet the problem persists
    – mylord
    Oct 20, 2017 at 4:41
19

If you install the composer as global on Ubuntu, you just need to find the composer location.

Use command

type composer

or

where composer

For Mac users, use command:

which composer

and then just remove the folder using rm command.

3
  • which composer for macos.
    – tolga
    Aug 27, 2019 at 9:04
  • Thanks, helped my day. Jul 28, 2020 at 15:40
  • For mac users - which composer will be used. I'll add it to the answer.
    – Harshit
    Oct 29, 2020 at 8:48
10

Is this the way you installed it?

curl -sS https://getcomposer.org/installer | sudo php
sudo mv composer.phar /usr/local/bin/composer
export PATH="$HOME/.composer/vendor/bin:$PATH"

If you have installed by this way simply delete composer.phar from where you put it.

In this case path will be:

/usr/local/bin/composer

Run this command:

sudo rm /usr/local/bin/composer/composer.phar

Note: There is no need to delete the exported path.

9

Find the Location of the Composer by typing this command

whereis composer

Then You will get the output like this

composer: /usr/local/bin/composer

Then:

cd /usr/local/bin/

And remove composer by this command

sudo rm -r composer

Not the answer you're looking for? Browse other questions tagged or ask your own question.