I created a new Laravel project. When I go to the terminal to install the dependecies composer
displays the following warning:
Cannot create cache directory /home/w3cert/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache.
sudo composer self-update
on Linux, since the ~/.composer
directory will be owned by root
, afterwards.
When you installed composer pretty sure you used $ sudo
command because of that the ~/.composer
folder was created by the root.
Run this to fix the issue:
$ sudo chown -R $USER $HOME/.composer
Change the group permission for the folder
sudo chown -R w3cert /home/w3cert/.composer/cache/repo/https---packagist.org
and the Files folder too
sudo chown -R w3cert /home/w3cert/.composer/cache/files/
I'm assuming w3cert is your username, if not change the 4th parameter to your username.
If the problem still persists try
sudo chown -R w3cert /home/w3cert/.composer
Now, there is a chance that you won't be able to create your app directory, if that happens do the same for your html folder or the folder you are trying to create your laravel project in.
sudo composer self-update
w3cert:w3cert
([OWNER][:[GROUP]]
)
.composer/
directory and sudo chown $USER -R /cache
that helped.
Change ownership of your .composer directory:
sudo chown -R $USER $HOME/.composer
$USER
is your username and $HOME
is your home directory.
chmod 777
is always a bad idea. And to get your username simply use the environment variable $USER
. I've edited your answer accordingly.
Use this command:
sudo chown -R $USER ~/.composer/
Success story sharing
$USER
with$USER:$USER
to fix not only the user but also the group of the folder and its contents.