Updating your PATH in Terminal (OSX)
When you ask your computer to run a program, it needs to be able to find the program's executable files. The PATH is its 'official' list of places to look.
You can have Terminal add locations to your PATH each time you open it. To set this up, you need to create a 'bash profile' ('bash' being the language that Terminal runs in), which Terminal will read each time it launches. The bash profile can list locations that Terminal adds temporarily to the computer's PATH.
These steps show how to do that, in particular for adding Ruby to your PATH after installing it with Homebrew.
cd ~/to go to your home folder. (Your Terminal might already be in the home folder, but this just makes sure.)
touch .bash_profileto create your new bash profile file. (It's fine if the file already exists, it won't be overwritten.)
To open the file for editing, enter
open -e .bash_profile. Unless you've set a different editor as your default, it will open in TextEdit.
Paste this line into the file (if there is already anything there, add it on a new line at the end):
Well, not exactly. That's a template for adding any location to your PATH. You must replace
/path/to/binwith the path to the folder location that you need in your PATH. For instance, to add Ruby 2.6.0 installed by Homebrew, you'd use:
You may need to use Finder to figure out the correct folder location. To jump to a folder like
/usr/local/in Finder, use the 'Go > Go to Folder' menu option and enter
Save and close the
In Terminal, enter
. ~/.bash_profileto reload the profile without relaunching Terminal. (You can also just close and reopen Terminal.)
You can now forget about the bash profile, at least until you need to change it or add another location to your PATH.