Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to find composer's global packages?

For a plugin for Sublime Text I was required to install a composer package globally.

In order to do this I had to run the following command:

composer global require "asm89/twig-lint" "@stable" 

The installation started running and a few seconds later the package was installed. Voila! Well, not really.

Step two was to add some lines to my Sublime Text configuration file:

{     "user": {         "paths": {             "windows": ["C:\\Users\\yourname\\.composer\\vendor\\bin"]         },     } } 

However, the plugin is not working. So I decided to check the path. And it appears there is no .composer directory in my profile directory. It isn't in my php directory either. And I can't find it anywhere.

I would like to know if there's a way to locate this directory and would appreciate any suggestions that can help me get this plugin to work.

like image 979
Peter Avatar asked Jun 05 '15 10:06

Peter


People also ask

Where are global composer packages installed?

This will install PHPUnit and all its dependencies into the ~/. composer/vendor/ directory and, most importantly, the phpunit CLI tools are installed into ~/. composer/vendor/bin/.

How do I see what packages are installed on composer?

You can run composer show -i (short for --installed ). In the latest version just use composer show .

Where are composer files located?

It typically should go in the top-most directory of your project/VCS repository. You can technically run Composer anywhere but if you want to publish a package to Packagist.org, it will have to be able to find the file at the top of your VCS repository.

Where does composer get packages from?

Composer downloads directly from the source, e.g. Packagist only knows those source and tells your composer instance where to go. It does this by downloading a bunch of json files from Packagist.org that have all the infos.


2 Answers

You can query Composer to find where it has set the user $COMPOSER_HOME directory.

composer config --list --global 

The [home] ... line refers to the default value of $COMPOSER_HOME.


The word home can be used as a single parameter as well to show the configuration value.

Example (Windows):

> composer -n config --global home                 C:\Users\<user>\AppData\Roaming\Composer 

Example (Linux):

$ composer -n config --global home                 /home/<user>/.composer 

Just as a final confirmation - the 'yourname' part in the configuration, would very likely need to be updated with your own Windows username - composer config will say where it put the files.

like image 119
Alister Bulman Avatar answered Sep 18 '22 23:09

Alister Bulman


You can use

composer global config bin-dir --absolute 

Example

PATH=$(composer global config bin-dir --absolute --quiet):$PATH 

You need --absolute to get value expanded, and --quiet to discard diagnostics of composer global changing working directory. This was tested with composer 1.10.16 and 2.0.1.

See https://github.com/composer/composer/issues/9354#issuecomment-716827067

like image 34
glen Avatar answered Sep 20 '22 23:09

glen