Composer global require Laravel/Installer not working on Ubuntu
I had the same problem and after reading this answer I solved it updating the .composer
folder permissions:
sudo chown -R $USER:$USER /home/$USER/.composer
Where $USER
is your machine's username.
Update: As @Lucas Bustamante pointed, you don't need to change $USER for your username, its an environment variable already.
As Ian Warner commented out, is not a good idea to run composer as sudo user, because it can lead to security issues.
JonnySerra
I don't really have much to say right now, i'm a pretty average person xD
Updated on June 05, 2022Comments
-
JonnySerra almost 2 years
I'm trying to run
composer global require "laravel/installer"
on my Ubuntu machine (Trenta OS Distro) and for some reason I can't get it to install.file_put_contents(./composer.json): failed to open stream: Permission denied
I get the error above on every attempt. I've been unable to find any help on google so I'm guessing this isn't a very common problem. I tried
whereis
command on that file and it gives me a location/usr/local/bin/composer
I tried running
chmod -R 777
on that file but it did nothing. I don't know what else to do.Composer was installed on my machine with the following command
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
I thought
composer.json
only comes with projects, but I shouldn't need an existing project in order to simply set up the Laravel Installer right?