MacOS – Homebrew in bash profile

bashhomebrewmacosterminal

I'm having an issue with my bash profile on my mac. Given the following from my .bash_profile

FOO="$(brew --prefix coreutils)/libexec/gnubin"
BAR="$(brew --prefix ruby)/bin"
BAZ="$(brew --prefix python)/bin"

The first line successfully completes, but the two following lines print the following error when I start terminal

-bash: brew: command not found

When I run brew --prefix ruby or brew --prefix python at the command line after terminal starts, it prints out their respective paths.

Can anybody figure this out?

Best Answer

The brew command is in /usr/local/bin, so you need to ensure that you either use the full path to brew in your commands, i.e. /usr/local/bin/brew or you need to set your PATH environment variable in your profile before using brew, e.g.:

export PATH=/usr/local/bin:$PATH