if you have installed composer using sudo
, or with a user different to the owner of .composer folder, as mentioned by @PhoneixS
Check if this is the case, by running:
ls -al ~/.composer
which may return
ls -al .composer
total 16
drwxr-xr-x 2 root root 4096 May 1 15:04 .
drwxr-xr-x 53 user-name user-group 4096 May 1 15:07 ..
-rw-r--r-- 1 root root 799 May 1 15:04 keys.dev.pub
-rw-r--r-- 1 root root 799 May 1 15:04 keys.tags.pub
Then:
- if the owner of .composer is the root user, running the
command with
sudo
, as fallow sudo php composer-setup.php
,will fix the issue
- if the owner is root but you don't want to have to run composer as root, then you can change the owner-user:owner-group of .composer to the current user as follow:
sudo chown -R owner-user:owner-group ~/.composer
- if the owner of .composer is the a different user than user-name, then you can run the command as that specific user, using
su