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.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Lazarus Rising
  • 2,597
  • 7
  • 33
  • 58
  • What do you mean by "but the installation was not successful"? Would you care for fixing installation? – Tomas Votruba May 22 '15 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. – Lazarus Rising May 23 '15 at 09:16

6 Answers6

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.

Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
  • Where is the composer file? – munchschair Mar 11 '16 at 20:49
  • 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. – Basheer Kharoti Apr 22 '16 at 11:00
  • @BasheerAhmed This question was related to installation on linux machine and it seems like you are using windows. – mshakeel Apr 27 '16 at 10:45
  • @BasheerAhmed Good point, Ahmed! I've updated my answer and included that. Thank you. – Jens A. Koch Apr 27 '16 at 14:48
  • 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". – Mikiko Jane May 04 '16 at 23:41
  • 8
    The composer cache folder is sometimes at `/home//.config/composer` – calvin May 31 '17 at 16:52
  • 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 05 '17 at 12:06
  • 2
    Just use the uninstaller located at C:\ProgramData\Composer\bin – Adrian P. Sep 08 '17 at 18:10
  • I can't find composer.phar in debian even after updatedb and locate composer.phar – mylord Oct 20 '17 at 04:45
  • 1
    if someone with macOS searching for it , then you can fire `$ which composer` in terminal and you will get composer's location – Sid Feb 02 '18 at 15:21
  • I can't find the.composer.phar on windows. I use the windows compser version! How can I to uninstall the composer? – robspin Apr 17 '18 at 07:11
  • To be really complete in Windows you may also have to remove it from your PATH – Stephen R Sep 12 '18 at 21:56
  • not make sense, it is a big `apt` package as Pažout answer, or really only one file as here? Please explain... – Peter Krauss Jul 26 '19 at 20:13
  • Its just one file. Plus some additional cache folders.. The OP fetches this file using Curl. -- But its also possible that someone wrapped this file into an AptPackage for (easier) installation on linux/debian distros. – Jens A. Koch Jul 27 '19 at 00:13
51

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

Pažout
  • 2,061
  • 20
  • 10
  • 3
    not make sense, it is [one file as jens's answer](https://stackoverflow.com/a/30399584/287948) or an `apt` package? Please explain... – Peter Krauss Jul 26 '19 at 20:12
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
hakre
  • 193,403
  • 52
  • 435
  • 836
drakonli
  • 2,304
  • 23
  • 29
  • 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. – Lazarus Rising Oct 06 '17 at 07:27
  • 1
    on debian I don't have those files, and yet the problem persists – mylord Oct 20 '17 at 04: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.

Harshit
  • 1,510
  • 19
  • 42
robspin
  • 771
  • 3
  • 14
  • 33
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.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Mahtab Alam
  • 315
  • 3
  • 8
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
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Zenonymous
  • 149
  • 2
  • 4