How to place the ~/.composer/vendor/bin directory in your PATH?
Solution 1
To put this folder on the PATH environment variable type
export PATH="$PATH:$HOME/.composer/vendor/bin"
This appends the folder to your existing PATH, however, it is only active for your current terminal session.
If you want it to be automatically set, it depends on the shell you are using. For bash, you can append this line to $HOME/.bashrc
using your favorite editor or type the following on the shell
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
In order to check if it worked, logout and login again or execute
source ~/.bashrc
on the shell.
PS: For other systems where there is no ~/.bashrc
, you can also put this into ~/.bash_profile
PSS: For more recent laravel you need to put $HOME/.config/composer/vendor/bin
on the PATH
.
PSSS: If you want to put this folder on the path also for other shells or on the GUI, you should append the said export
command to ~/.profile
(cf. https://help.ubuntu.com/community/EnvironmentVariables).
Solution 2
Detailed instructions:
in your ~/.bashrc add these lines:
export PATH="$PATH:~/.composer/vendor/bin"
Then reload:
source ~/.bashrc
Check if its added correctly:
echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/web/bin:~/.composer/vendor/bin
Solution 3
In Ubuntu 16.04 LTS with composer globally installed, this worked for me.
Edit the .bashrc file in your home directory puting the path to the composer bin folder that is located in /your/home/.config/composer/vendor/bin
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc
source ~/.bashrc
If not works, verify the path to the composer bin directory and close and reopen the terminal. Otherwise, try to logoff and login in the Ubuntu.
Also works in ubuntu 18.04. Thanks @chifliiiii for your feedback.
Solution 4
For setting the PATH on Yosemite (OS X 10.10.5), use the command below:
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile
To reload either quit terminal and start up again or use:
source ~/.bash_profile
Helped me, hope it helps someone else out there!
Solution 5
I did all of the above and it didn't work for me.
I just copied this into my terminal and it worked for me.
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Related videos on Youtube
which1ispink
Updated on December 27, 2021Comments
-
which1ispink over 2 years
I'm on Ubuntu 14.04 and I've been trying all possible methods to install Laravel to no avail. Error messages everything I try. I'm now trying the first method in the quickstart documentation, that is, via Laravel Installer, but it says to "Make sure to place the
~/.composer/vendor/bin
directory in yourPATH
so the Laravel executable is found when you run the Laravel command in your terminal." so my question is, how do I do that? This may be a simple question but I'm really frustrated and would appreciate any help. -
sunnysidedown916 about 9 yearsThx! I'm not too familar with unix and this made total sense! (And dollars!)
-
Michiel almost 9 yearsWorks like a charm here, on ubuntu 14.04. You might wanna logout/login and/or open a fresh terminal window if things don't seem to work.
-
phaberest over 8 yearsThank you @forca001 in my
.zshrc
it was not working using~
and it finally did with$HOME
-
phaberest over 8 yearsYou should use
$HOME
instead of~
in the composer path. Not sure about bash, but it is certainly necessary when you're setting it in zsh's.zshrc
. -
Askar over 8 yearsNice! This worked for me as well on Mac OS X El-Captain.
-
waweru almost 8 yearsIt should be noted that on Ubuntu 16.04 running laravel 5.1, the path is: ~/.config/composer/vendor/bin
-
Abhishek Goel over 7 years@grit45 can you please explain why it worked a little bit
-
JoshP over 7 yearsAlternatively, I needed to edit my ~/.zshrc as I'm using oh-my-zsh with iTerm2. Otherwise... same instructions... cheers!
-
nclsvh about 7 yearsI have tried this, no luck! Also I do not have a directory called ./composer/vendor. I only have .composer and in there i have a cache folder.. Been searching for 2 days now.
-
nclsvh about 7 yearsThe thing I echo $PATH does not include the composer part.. I have literally added it over 100 times in all the possible ways, rebooted about 5 times an reloaded bashrc.. nothing. Any idea?
-
Brainmaniac almost 7 yearssource ~/.bashrc --- I have to do this each time i should laravel. This is the best answer for me
-
Izac Mac almost 7 yearsabsolute champion. thanks mate. waisted 10 min trying to do it. your solution worked like a charm
-
CecilMerrell aka bringrainfire over 6 yearsecho 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc was missing the .config directory THEN execute source ~/.bashrc
-
Abdelsalam Shahlol over 6 yearsWorked with Parrot OS 3.8
-
ottz0 over 6 yearsThis works, when you run composer laravel installer, it changes directory to Changed current directory to /home/username/.config/composer ./composer.json has been updated as per the path in this answer
-
Ken over 6 yearsBoth .composer/vendor/bin and .config/composer/vendor/bin contain "laravel" for me on Ubuntu 16.04 for what it's worth, so both work.
-
GabMic over 6 yearsThis is the one that worked for me on ubuntu 17.10. Thanks.
-
MrTux about 6 yearsThis question is about putting some directory on the path and not how to install composer.
-
Christian Bonato almost 6 yearsWorks on OS X El Capitan.
-
Ryan Coolwebs over 5 yearsThis is the only answer that worked for me on my Mac running OSX Mojave. Thanks heaps!
-
MrTux about 5 yearsWhat is the improvement to the existing answers?
-
MrTux about 5 yearsWhat is the improvement to the existing answers?
-
OMi Shah over 4 yearsThis should be the accepted answer. Worked with MacOS Majave 14.x
-
Sharifur Robin about 3 yearsyou have saved my time, i was searching for 2hr
-
Roman Kozin almost 3 yearsFor Linux Mint 20.2 it was
$HOME:~/.config/composer/vendor/bin:$PATH
-
Vladimir Vukanac over 2 yearsGet the path by composer it self: stackoverflow.com/a/69125272/2873481
-
Renato Francia over 2 yearsWorked like a charm on 20.04.
-
Jet Ezra over 2 yearsSeems to work for me