Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When installing Laravel I got an error: "./composer.json is not writable."

This is the command I run:

composer global require "laravel/installer" 

and this is the text and error I got after that:

Changed current directory to /home/dimitar/.composer ./composer.json is not writable. 

I'm running Ubuntu 16.04 LTS and PHP 7 and Composer version 1.3.0 and running this command from my home folder.

like image 700
Dimitar Avatar asked Jan 03 '17 17:01

Dimitar


People also ask

What is composer json in Laravel?

json. The composer. json file also allows you to give your project a name, version and a few other details, which can be used to publish your own Composer packages to Packagist. Once you're happy with the dependencies you have defined; it's time to install them. Go to your command line and type composer install.

How do I download composer for Laravel?

Via Download Once Composer is installed, download the 4.2 version of the Laravel framework and extract its contents into a directory on your server. Next, in the root of your Laravel application, run the php composer. phar install (or composer install ) command to install all of the framework's dependencies.

Where do I put composer json?

composer. json is a JSON file placed in the root folder of PHP project. Its purpose is to specify a common project properties, meta data and dependencies, and it is a part of vast array of existing projects.


2 Answers

Check the owner of composer.json.

ls -lh ~/.composer/composer.json 

If it's 'root', run:

sudo chown -R yourusername:yourusername ~/.composer/composer.json 

While in the .composer folder, check the 'cache' folder owner. If it's 'root', re-run above command but switch composer.json to the cache. Otherwise, you may end up with a 'Cannot create cache directory' warning.

like image 78
PelleLV Avatar answered Sep 21 '22 08:09

PelleLV


The error says it all, there is a problem with permissions. I guess easiest way to fix this is running this command:

sudo chmod -R 775 /home/dimitar 
like image 34
Alexey Mezenin Avatar answered Sep 21 '22 08:09

Alexey Mezenin