Closed donquixote closed 6 years ago
Install composer globally for all users
I think the common way to install composer already makes it available globally to all users. E.g. like this, https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-14-04
Install cgr globally for all users. Let cgr install all commands globally for all users.
I found this, https://stackoverflow.com/a/33381090/246724 But so far it is not working.
cgr is a pretty simple program. As long as it is chmod +x for all users and exists in a global $PATH, it will work.
The details of managing the global $PATH, install location and owning user for global commands may vary from platform to platform and is beyond the scope of the documentation for this project.
For anyone coming here: I managed to make it work, basically following https://stackoverflow.com/a/33381090/246724
I put this in /etc/environment
:
PATH="/usr/local/composer/vendor/bin:[..]"
COMPOSER_HOME="/usr/local/composer"
(The [..] in PATH is whatever was there before. Alternatively, one can use PATH="/usr/local/composer/vendor/bin:$PATH"
.)
n.b. COMPOSER_HOME
is in general something like $HOME/.composer
or similar. If you choose to share one COMPOSER_HOME
among all users, then any software globally installed (e.g. via composer global require
or cgr
) by any user will be in the executable path of all users on the system.
If you do not want to give every user the ability to install software for all users, then you could set the PATH as described above, install cgr
to /usr/local/composer
, and keep COMPOSER_HOME
as it is (do not define it in a global location such as /etc/environment
, and allow it to default to $HOME/.composer
).
So far I have always installed cgr commands in my home directory,
~/.composer
. This means the commands are only available to me.Is there a recommended way to do it system-wide for all users? So.
I might figure this out if I tried a little harder.. but I think it does make sense to document a recommended / standard way of doing this.