-1

What I'm trying to accomplish:

Create a new Laravel project

What I'm trying:

I've been trying to follow the installation instructions

  1. sudo composer global require laravel/installer
  2. export PATH="/home/hedwin/.composer/vendor/bin:$PATH"

When I try to run the following command:

sudo Laravel new trainingLaravel

it returns this error:

sudo: laravel: command not found

You can see my picture for details : Terminal

I'm on ubuntu 18.04.

Thanks a lot for every help..

FullStackOfPancakes
  • 1,351
  • 1
  • 17
  • 30
Hedwin Bonnavaud
  • 123
  • 2
  • 12
  • 2
    Welcome, where on that page does it say to use `sudo` to install the installer? It's `composer global require laravel/installer` – brombeer Dec 20 '19 at 12:25
  • i need rights to write in ./composer.json, so output is : "Cannot create cache directory /home/hedwin/.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache Cannot create cache directory /home/hedwin/.composer/cache/files/, or directory is not writable. Proceeding without cache ./composer.json is not writable. " but thx for this kind and usefull answer, maybe "Why did you used sudo?" will be better right ? – Hedwin Bonnavaud Dec 20 '19 at 12:57
  • If you are logged in as user "hedwin" and your home directory is `/home/hedwin` you have full rights inside that folder, so there should in theory be no warnings about directories not being writable. If however, you fiddled around with using `sudo` your `.composer` directory might be owned by `root` and then in fact, the folder is not writable by user "hedwin". sudo remove the `.composer` folder and all its subfolders and `composer global require laravel/installer` again – brombeer Dec 20 '19 at 13:44

2 Answers2

1

edit : problem unsolved, i completely remove laravel/installer

composer global remove laravel/installer

then i redo installation in /home/hedwin/ directory :

https://gist.github.com/zunayed93/80ba8611a88623c20f9bb6c7b4e25792

but my way to add /vendor/bin dir. to the path didn't work so i follow instructions at Laravel PHP Command Not Found

"Ok, I did that and it works:

nano ~/.bash_profile 

And paste

export PATH=~/.composer/vendor/bin:$PATH

do source ~/.bash_profile "

and finally command laravel new something works !

Hedwin Bonnavaud
  • 123
  • 2
  • 12
0

found solution :

sudo chown -R hedwin ~/.composer/composer.json sudo chown -R hedwin /home/hedwin/.composer/cache/repo/https---repo.packagist.org/ sudo chown -R hedwin /home/hedwin/.composer/cache/files/

or : "sudo chown -R hedwin ~/.composer/" is the same

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

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

Hedwin Bonnavaud
  • 123
  • 2
  • 12