When you run any composer global
command, the composer.json
used is the one at your HOME directory, not at your projects directory. E.g. at ~/.composer/composer.json
.
Looks like your home directory composer is owned by root.
At some point you've executed composer
with root and messed up your installation.
To find out where your composer's home directory is at, you should run this (as shown here):
composer config --list --global | grep home
E.g. given your output, it seems your home directory sits at "/home/rukon/.config/composer":
So you'd need to run:
sudo chown -R $USER: ~/.config/composer
To fix your "global" composer configuration directory.
You should be able to run composer global
commands after that.
If you have more permissions problems, you'd better fix your home directory so everything in there is owned by your user, and nothing by root as shown here:
sudo find ~ -type d -user root -exec sudo chown -R $USER: {} +
For a regular installation the above should be safe (all the files in your home directory belong to to your own user), but if you have anything special in there you should probably be aware and take a more surgical approach (checking each directory).
./composer.json
refers to/home/rukon/.config/composer/composer.json
right? – apokryfos