Unable to write keys.dev.pub to: /home/ubuntu/.composer
try
sudo apt-get install composer
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 fallowsudo 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
It can happen when you have a previous installation of composer not completely removed or if you are running the installer with a user different to the owner of .composer
folder.
You can rename the old folder (to have a backup) and then try again:
mv ~/.composer ~/.composer.old
This is less risky than executing something unknown with sudo.
While installing the Composer in your Project Directory you may Get this error. Im Using the Ubuntu 16,While installing i faced the Same Issue
All settings correct for using Composer Unable to write keys.dev.pub to: /home/ubuntu/.composer
Step 1: just go to your Project Directory and run a Command
sudo su
Step 2: then Try to install the Composer using The Following Command
curl -sS https://getcomposer.org/installer | php