How do I place the ~/.composer/vendor/bin directory in your PATH using .zshrc
Asked Answered
M

6

11

This may be a very noob question, but I'm trying to install Homestead on my Mac. I'm following installation steps via http://laravel.com/docs/4.2/homestead however there is a point in the installation process where it state "Make sure to place the ~/.composer/vendor/bin directory in your PATH so the homestead executable is found when you run the homestead command in your terminal." How do I do this using zsh? Thanks!

Mont answered 2/12, 2014 at 21:4 Comment(0)
J
11

in whichever profile you're using (.zprofile or .profile or whatever), you would add the line:

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

then reload your profile

source ~/.zprofile
Jun answered 2/12, 2014 at 21:15 Comment(7)
How do I access .zprofile? I tried vi ~/.zprofile but it only creates a new fileMont
Then you're not using .zprofile. See which profile file you're using already; could be ~/.profile or ~/.bash_profile or ~/.bashrc, or ~/.zshrc. there's a few more but those are the most common.Jun
I can access ~/.zshrc however when I put PATH = ~/.composer/vendor/bin:$PATH , save and source ~/.zshrc I get /Users/username/.zshrc:83: command not found: PATHMont
Never mind, got it. added export PATH=/Users/username/.composer/vendor/bin:$PATH Thanks for your help Paul!Mont
That "source ~/.zprofile" was what I was missing. ThanksVioletavioletta
I had the same issue until I added export PATH=/Users/username/.composer/vendor/bin:$PATH. I tried adding export PATH=~/.composer/vendor/bin:$PATH as recommended in the Laravel page but couldn't make it work, luckly I found this thread. Thanks @MontShoemaker
I found for me I had to give the full path rather than using ~ then it worked.Severn
C
11

If your PATH is in .bashrc file :

echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc

If your PATH is in .zshrc file :

echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.zshrc

Finally, you should restart your environment

source .bashrc #Bash

source .zshrc #ZSH

Caelian answered 29/9, 2017 at 12:2 Comment(1)
I had to type "source .bashrc" to make it work afterKarli
H
3

Update the file ~/.bashrc like this:

PATH="~/.composer/vendor/bin:{$PATH}"
Hewie answered 4/4, 2015 at 3:50 Comment(0)
A
3

Setup

Mac OS:

echo 'export PATH=$PATH:$HOME/.composer/vendor/bin' >> ~/.zshrc

Linux:

echo 'export PATH=$PATH:$HOME/.config/composer/vendor/bin' >> ~/.zshrc

To apply restart terminal or:

source ~/.zshrc

To check if it works:

echo $PATH
Arwood answered 31/8, 2020 at 15:55 Comment(0)
C
2
$ echo 'export PATH=$PATH:$(composer global config bin-dir --absolute --quiet)' >> ~/.zshrc

TLDR;

A bit more automatic approach to get global vendor/bin path:

$ composer global config bin-dir --absolute
/Users/me/.composer/vendor/bin

In currently open terminal updating PATH will work:

$ PATH=$(composer global config bin-dir --absolute --quiet):$PATH

As it's expected to have global tools always available, we can add it in ~/.zshrc or others, plus:

  • consider a difference should it be prepended or appended to the PATH,
  • and use single quotes:
$ echo 'export PATH=$(composer global config bin-dir --absolute --quiet):$PATH' >> ~/.zshrc
Classics answered 9/9, 2021 at 22:19 Comment(0)
S
1

In one of your start files within home directory (~/.bashrc or ~/.zshrc)

export laravel=/Users/username/.composer/vendor/bin
export PATH="$laravel:$PATH"
Stroke answered 10/2, 2015 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.