homebrewwindows-subsystem-for-linuxkali-linux

how to keep homebrew in my path after closing the terminal window?


I run kali linux on wsl2. I installed homebrew and it works until i close the terminal window or open another terminal window the terminal doesnt recognise the brew command.

i tried reinstalling homebrew and follow youtube tutorials on installing homebrew on linux and on wsl2. the command i use to add homebrew to my path is:

eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

and to install homebrew is:

sudo apt-get install build-essential
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Solution

  • You're missing the important step of adding Homebrew to your path.

    With the current implementation you can only run brew in the same folder you installed it, that's why it's not working just running "brew"

    test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
    
    test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
    
    test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bash_profile
    
    echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile
    

    You'll need to run each line seperately, after this, the brew command should work.

    You can read more about it on the official site