Unless you enjoy sudo changing permissions on files in /usr and searching for instructions on how to uninstall things cleanly (check out these answers on Stack Overflow), you might want to change up how you install homebrew on your mac.

This post outlines a clean way to install brew and programs with brew.


Instead of running curl or piping a shell script, we’re going to clone brew itself and run it directly. Don’t worry, you don’t have to compile anything, just clone it.

> git clone [https://github.com/Homebrew/brew](https://github.com/Homebrew/brew) ~/git/brew

You can now run brew directly at ~/git/brew/bin/brew, but that’s not so convenient, so let’s see what else we can do to improve from here.

It turns out when you install programs with brew, they all get installed to the same directory brew lives in, namely ~/git/brew/bin/. So all you need to do now is add ~/git/brew/bin/ to your shell’s path.

For bash users, this can be done by adding this line to ~/.bash_profile:

export PATH="$PATH:$HOME/git/brew/bin"

Now brew will be available from your shell, along with any other programs you install with brew.

If you use a different shell, you can search for instructions on how to modify the PATH environment variable.


If you ever want to uninstall brew and all the programs you’ve installed with it, just remove the whole directory.

rm -rf ~/git/brew