Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Composer create-project execution for Laravel fail?

It appears that unless I use sudo my composer command fails to create a Laravel project.

Without sudo it gives me the following error:

[ErrorException]                                                             
  copy(/Users/H/.composer/cache/files/laravel/laravel/73094f2633f1b90f3ef  
  6de4a8a5b610532510e0e.zip): failed to open stream: Permission denied  

What am I missing here?

like image 499
kaizenCoder Avatar asked Dec 12 '22 07:12

kaizenCoder


1 Answers

If you ever execute:

sudo composer <anything>

Some of your composer home files (~/.composer/) will be written by the root and if you can't delete or write over them again unless you use sudo to become root, so you have 2 options:

1) Change the user of those files back to your own:

sudo chown $USER:$USER -R ~/.composer

Or on a mac

sudo chown -R $USER:staff ~/.composer

2) Delete the whole folder (and lose your cache) to restart from scratch:

sudo rm -rf ~/.composer/cache

or even

sudo rm -rf ~/.composer
like image 67
Antonio Carlos Ribeiro Avatar answered Feb 23 '23 14:02

Antonio Carlos Ribeiro