Search code examples
homebrewlaravel-valet

'Zsh: command not found: valet' - unable to install Valet


I just tried installing valet for a very long time, - and I couldn't find any help anywhere. No matter what I tried, then it kept saying:

Zsh: command not found: valet

I'm running Zshell (instead of Bash) and OSX. I've had Brew installed for quite a while.

I'll answer this myself, - so hopefully people in the same situation can find this in the future.


Solution

  • Everywhere it says to 'Check that your path is right'. And yup - if you haven't done that, then you should start there. The easiest way is to go to your terminal and write:

    echo $PATH
    

    ... And then you should see ~/.composer/vendor/bin in between two colons in there. If that isn't there, then you should go to your ~/.bashrc-file (or ~/.zshrc-file) and add this line:

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

    And then it may be fixed.

    My problem had deeper roots, though. Even though my path was right, then I still got the error:

    Zsh: command not found: valet
    

    And if I wrote: which valet - then it (obviously) just responded with valet not found.

    Removal of Composer

    What fixed it was to remove all my composer-installations. Composer can be located in several different locations (and installed by brew). So in order to remove it, then do this (inspired by this post, but it lacks a couple of steps):

    • Remove your composer- or -composer.phar-file. You can find them by running which composer and/or which composer.phar.
    • Remove your .composer-folder (usually located here: ~/.composer).
    • Then make sure that there isn't an installation done with Homebrew (this was what I think made the collision for me). You do it by running brew unlink composer followed by brew remove composer.
    • Then, - if you want to be 100% sure that it's all gone, then go to your root (cd /) and run this command: find ./* -name 'composer.phar' and this find ./* -name 'composer'. That should tell you of all the locations where the Composer-installation can be installed.

    When all that's removed, then you should be rid of Composer (entirely). ... Then install it again, - and see if you can get valet to work (it did for me).