Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: command Not found [duplicate]

I feel like a moron for having to ask this, and I've gone through all the similar questions to no avail. I am running Ubuntu 14.04 in a vagrant vm on a mac. I have composer installed and i have run these commands:

composer global require "laravel/installer"

(this appears to have worked and shows that laravel is one of things that was downloaded)

I have also added this line to the .bashrc

export PATH="∼/.composer/vendor/bin:$PATH"

Note, i added this to both the vagrant user as well as the root users .bashrc file. I have logged out and back into the shell and verified the path with this command:

echo $PATH

Which gives me this:

∼/.composer/vendor/bin:∼/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

and the command itself that fails is this

laravel new test

I don't see what i could be missing, any ideas?

like image 519
Dallas Caley Avatar asked Feb 04 '16 21:02

Dallas Caley


3 Answers

It is better to use $HOME instead of just ~.

In my .zshrc(I use zsh) I have it working this way

export PATH="$PATH:$HOME/.composer/vendor/bin"

Make sure your terminal does actually use .bashrc and not maybe .bash_profile, if that is the case you should edit that file. If you are using it from the VM, the user you log in with when you call vagrant ssh is vagrant, not root.

In addition, remember to source the file after the edit, or open a new terminal.

UPDATE

I see there are answers that put the $PATH after composer's path, so I thought I could tell you what I learned to be the difference.

It's not a random thing you can put whatever way you want. What you put after overwrites what comes before. You're gonna need to know it if you want to use packages that overwrites anything installed in paths that are already in PATH.

That means that if you have something installed on your system and you install a newer version of the package using composer, it will have the same command to start so if the composer path will not be after the system path, you'll have to reference the full path to the binary inside composer's vendor/bin to execute it.

like image 145
phaberest Avatar answered Nov 05 '22 14:11

phaberest


Open your terminal and run these given lines:

For zsh and bash:

export PATH="$HOME/.config/composer/vendor/bin:$PATH"

source ~/.zshrc
source ~/.bashrc

For bash only:

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

source ~/.bashrc
like image 22
Md Rasel Ahmed Avatar answered Nov 05 '22 12:11

Md Rasel Ahmed


If you put the tilde (~) inside quotes it won't be translated to your home directory. Run this and it should work:

export PATH=∼/.composer/vendor/bin":$PATH"
like image 3
ManiacTwister Avatar answered Nov 05 '22 13:11

ManiacTwister