Cannot create cache directory .. or directory is not writable. Proceeding without cache in Laravel

PhpLaravelComposer Php

Php Problem Overview


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.

Php Solutions


Solution 1 - Php

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

Solution 2 - Php

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.

Solution 3 - Php

Change ownership of your .composer directory:

sudo chown -R $USER $HOME/.composer

$USER is your username and $HOME is your home directory.

Solution 4 - Php

Use this command:

sudo chown -R $USER ~/.composer/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKarthikView Question on Stackoverflow
Solution 1 - PhpJim MView Answer on Stackoverflow
Solution 2 - PhpNesarView Answer on Stackoverflow
Solution 3 - PhpShrikant PardhiView Answer on Stackoverflow
Solution 4 - PhpOppaView Answer on Stackoverflow