91

I am trying to set up Laravels Valet (Valet is a Laravel development environment for Mac). Everything works until it comes to the command "valet install". This command must be executed in terminal. But I got the error "command not found". Any ideas, why? Do I have to update my PATH or something else?

I switched to OS X a few days ago. Before that, I was a windows user. So I am a total newbie.

1

20 Answers 20

293

Yes, you need to make sure that ~/.composer/vendor/bin directory is in your system's PATH, you can check this by running:

echo $PATH

If you can't see it there, then you need to add this to your ~/.bash_profile:

export PATH=$PATH:~/.composer/vendor/bin
11
  • 12
    This is the answer I keep finding, EVERYWHERE! Yet it does not solve my problem.. valet is still command not found. Is there something else that might be overlooked for some inexperienced developers?
    – nclsvh
    Mar 7, 2017 at 12:46
  • 19
    Maybe ur using zsh? If so add ~/.composer/vendor/bin to export PATH in ~/.zshrc
    – halfred
    Mar 16, 2017 at 21:36
  • 3
    and if its still not working then u need to close and reopen the terminal.
    – hatemjapo
    Feb 1, 2019 at 12:24
  • 7
    For me using ubuntu18.04, this path is a bit different though. It's ~/.config/composer/vendor/bin/ for some reason.
    – Fred Lai
    Jul 17, 2019 at 4:10
  • 3
    I modified the .bash_profile file directly using nano ~./bash_profile, added export PATH="$PATH:$HOME/.composer/vendor/bin" at end of file, saved, restarted terminal and it worked (I'm on Big Sur)
    – Kyle Yeo
    Dec 9, 2020 at 4:19
69

If you're getting the error message "valet: command not found", it's likely that PHP's Composer is not in your PATH variable, for instance:

$ valet install
-bash: valet: command not found

You can confirm if Laravel Valet was successfully installed by running the following command:

ls -al ~/.composer/vendor/bin/valet

If successfull, you'll see the symlink for Valet in Composer's bin directory pointing to Laravel in the vendor directory:

~/.composer/vendor/bin/valet@ -> ../laravel/valet/valet

To test whether your PATH is missing Composer, try running the Valet command directly:

~/.composer/vendor/bin/valet --version

If you're shown the Laravel version number, (e.g. Laravel Valet 2.0.4), this indicates Valet is installed but you need to update your PATH variable to include Composer for the valet command to work globally.

In your Terminal, execute the following command which will append Composer to your shell's PATH:

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

For the changes to take effect, you'll need to exit and re-open your Terminal window or tab.

Alternatively, you can simply source your shell's profile, which doesn't require quitting your active session:

source ~/.bash_profile

If you have a different shell environment or you're using a shell other than Bash, you will need to source its configuration profile instead (e.g. .bashrc, .zshrc, config.fish).

5
  • This test flow worked for me, I had just forgotten to restart the terminal Jan 30, 2019 at 11:31
  • The first steps seem to work, but when I try source ~/.bash_profile, I get ~/.bash_profile No such file or directory, then weather or not I close and open a new terminal window, I still get -bash: valet: command not found.
    – BBaysinger
    Mar 6, 2019 at 0:14
  • 1
    This answer mentions paths including ~/.composer, but I needed to change them to ~/.config/composer, as other answers on this page mentioned.
    – Ryan
    Jul 19, 2021 at 19:42
  • Had to update my path to /.config/composer too. Otherwise this works great. Mar 2, 2022 at 23:59
  • This flow worked perfectly for me using a M1 Mac, thank you!
    – DevSem
    Sep 4, 2022 at 2:07
39

I'm using oh-my-zsh so:

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

You may replace .zshrc with .bashrc

5
  • 2
    This worked for me. Zsh seems to require the full path to your home folder, rather than ~/. Jul 1, 2018 at 9:55
  • 6
    What worked for me echo "export PATH=$PATH:$HOME/.composer/vendor/bin" >> ~/.zshrc Jun 17, 2020 at 0:12
  • 1
    I've tried a ton of different posted solutions around the web for this and it was as simple as using $HOME instead of ~. Thanks!
    – krx
    Jul 26, 2020 at 19:02
  • 1
    @MohamedSaleh That works for me as well. :) Aug 13, 2021 at 10:57
  • This worked for me too. Mac M1
    – almiros
    Nov 17, 2023 at 13:56
23

you just have to use:

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

then

valet install

ready :)

1
  • Thank you so much, this worked for me.. My path before was pointing to '/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
    – Lukas
    Apr 1, 2023 at 16:30
17

Make sure that ~/.composer/vendor/bin directory is in your system's PATH, you can check this by running:

echo $PATH

If not there, open your ~/.bash_profile and add this code:

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

Then run:

composer global require laravel/valet --dev

Once it is done, run:

valet install
15

If valet install doesn’t work, but ~/.composer/vendor/bin/valet --version does work, try installing it via

~/.composer/vendor/bin/valet install

To See if that worked, check

valet --version
13

If you're using zsh, you cannot use ~ as path to home dir, use $HOME instead.

In .zshrc file, instead of adding this:

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

Add this and the path will resolve:

export PATH=$PATH:$HOME/.composer/vendor/bin
2
  • 1
    this is right in case for .zshrc also the location might be different like $HOME/.config/composer/vendor/bin
    – Min Somai
    Feb 28, 2022 at 9:31
  • This worked on my macOS Ventura as well by running the command export PATH=~/.composer/vendor/bin:$PATH
    – Franz
    Mar 14, 2023 at 23:35
9

If you have a fresh installation, you may not have the PATH variable contains your home path. So, adding the $HOME variable would require like the following:

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

1
  • Adding $HOME/ before .composer does the trick! It seems ZSH doesn't understand or pull the correct directory using ~. Jun 1, 2021 at 15:20
7

This command might solve your problem

test -d ~/.composer && bash ~/.composer/vendor/bin/valet install || bash ~/.config/composer/vendor/bin/valet install
4

In Ubuntu 18.04 do this:

echo "export PATH=$PATH:$HOME/.config/composer/vendor/bin" >> ~/.bashrc
source ~/.bashrc
1
  • Works with Ubuntu 20.04 As well
    – paulobunga
    Apr 10, 2022 at 14:39
2

with new composer installation, you need to add a new path which is

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

Then you need to

chown YOUR_USERNAME ~/.config

for accessing composer packages without sudo command.

2

I have installed Composer version 2 and found that composer default path is ~/.config/composer/ and similarly valet is also installed on /.config/composer/vendor/bin/valet. So to solve this issues I added the composer path to ~/.bashrc file as:

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

Add ~/.composer/vendor/bin directory to your PATH variable.

1

For me worked

write in console

  1. cd ~/.composer/vendor/bin
  2. pwd
  3. copy pwd command result
  4. export PATH=$PATH: (pwd command result)
  5. valet install

I think I explained well

1

I found a fix on this website, and it fixed my issue.

test -d ~/.composer && bash ~/.composer/vendor/bin/valet install || bash ~/.config/composer/vendor/bin/valet install

https://hidayatabisena.medium.com/solving-issues-command-not-found-laravel-valet-install-on-macos-mojave-2a7629759a9f

0

In my case I've to update /etc/profile file added

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

in

/etc/profile

then

source ~/etc/profile

0

In my case I found the valet location by manual search

enter image description here

Then add the the valet file path to PATH variable

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

Then I ran the install command and it worked

valet install
0

Php may be not installed

Use your prefered version with:

brew install php
// or
brew install [email protected]
// or
brew install [email protected]

This solved my issue.

0

iTerm Terminal Users / ohmyzsh 👇🏻

Step 1. vi ~/.zshrc

Step 2. mention below line anywhere

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

Save, Exit & Open a new Terminal. That's it ✌️

Now type valet -v

0

I think you just nid composer remove and install again next step you can download and install valet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.