Make sure that usr local bin is in your path

The PATH variable holds a list of directories separated by colons, so if you want to add more than one directory, just put a colon between them:

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

That syntax works in any Bourne-compatible shell (sh, ksh, bash, zsh...). But zsh, which is the default shell in recent versions of MacOS, also exposes the PATH another way - as a variable named (lowercase) $path, which is an array instead of a single string. So you can do this instead:

path+=(/usr/local/git/bin /usr/local/bin) 

In either case, you may want to check to make sure the directory isn't already in the PATH before adding it. Here's what that looks like using the generic syntax:

for dir in /usr/local/git/bin /usr/local/bin; do
   case "$PATH" in 
     $dir:*|*:$dir:*|*:$dir) :;; # already there, do nothing
     *) PATH=$PATH:$dir          # otherwise add it

And here's a zsh-specific version:

for dir in /usr/local/git/bin /usr/local/bin; do
  if (( ${path[(i)$dir]} > $#path )); then

I'm trying to install brew but get the following warning:

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:


Consider amending your PATH so that /usr/local/bin
is ahead of /usr/bin in your PATH.

I have no idea how to amend the path. I've explored several files from this stack overflow post (, but can't find a relevan path to edit. The only file that I do have that exists is my /etc/profile file which currently looks like:

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
export PATH

I wanted to just uninstall python then reinstall it through homebrew, but am a little nervous about breaking too many things at once.

Is there an easy way to amend the path? Should I create a .bash_profile file? Thank you for any help in advance.

Make sure that usr local bin is in your path

By August 18, 2022August 19, 2022

macos – Making sure /usr/local/bin is in my $PATH on mac

echo $PATH will print your path. If you see /usr/local/bin between some colons, then its in your path.

open terminal and type the command below

echo $PATH

You should see something like this


the presence of /usr/local/bin in the output means you are good to go

macos – Making sure /usr/local/bin is in my $PATH on mac

Related posts on Macos  :

  • macos – Java/JDK for the Apple M1 chip
  • macos – OpenSSL and Rand_bytes
  • macos – Setup local LDAP server in mac OSX
  • macos – Remote debugging using lldb/Xcode
  • macos – Gulp command not found after install
  • How do I get out of macOS X Utilities screen?
  • How do you get to macOS Utilities screen?
  • Does macOS High Sierra have Bluetooth?
  • macos – How to install pdftk on Mac OS X

Post navigation

In newer macOS versions custom executables belong in the directory /usr/local/bin. However, the path /usr/local/ is not included in the system’s default PATH variable. This article shows you how to add /usr/local/bin to the system PATH variable on macOS.

Since macOS El Capitan you cannot put any custom files under /usr/bin/. Even when you sudo as hard as you can (with administrator rights) you cannot touch the files in that directory. Therefore, you are forced to use /usr/local/bin for your custom executables. Also if you are using Homebrew to install programmes on your system, the programme executables will be installed under the path /usr/local/bin. However, the path /usr/local/ is not included in the system’s default PATH variable so you cannot e.g. use these executables from within your Java programmes. As a consequence, you most-probably want to add path /usr/local/bin to the system PATH environment variable to add the executables to your default executables.

Why not use the profile file?

Of course, you can easily add /usr/local/bin to the PATH environment variable by editing the profile file in ~/.profile and add the expression:

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

But does this really add the executables under the path /usr/local/bin to the default executables? The answer is no, it does not. For example, consider you are running a Java application that executes some system executables/programmes myex located in /usr/local/bin using the Runtime object:


The code above would result in an error because the default path configuration does not include /usr/local/bin because the default path configuration is usually something like /usr/bin:/bin:/usr/sbin:/sbin.

Changing the Java code

One workaround may be to change the Java code and explicitly source the .profile file containing the aforementioned export statement:

Runtime.getRuntime().exec("source ~/.profile; myex")

Another workaround may be to call the executable using its absolute path /usr/local/bin/myex:


Both workarounds would make strong assumptions either about the contents of the profile configuration or about the location of the executable.

As a result, the more elegant solution is to add the executable myex to the default executable path. This comment on github provides a way to achieve that. Open a Terminal window and copy & paste the following command:

sudo launchctl config user path /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

The command will set the default environment and add /usr/local/bin to the PATH variable of the system’s default environment. Hence, the executables under /usr/local/bin are callable from the default configuration.

How do I add usr local bin in my path Mac?

Method #1: $HOME/.bash_profile file to set or change $PATH under macOS.
Open the Terminal app on macOS..
The syntax is as follows using the export command to add to the PATH on macOS: ... .
In this example, add the /usr/local/sbin/modemZapp/ directory to $PATH variable. ... .
Append the following export command:.

How do I find my path on Mac?

Show the path to a file or folder On your Mac, click the Finder icon in the Dock to open a Finder window. Choose View > Show Path Bar, or press the Option key to show the path bar momentarily. The location and nested folders that contain your file or folder are displayed near the bottom of the Finder window.

How do I set path on Mac?

Mac OS X.
Open the . bash_profile file in your home directory (for example, /Users/your-user-name/. bash_profile ) in a text editor..
Add export PATH="your-dir:$PATH" to the last line of the file, where your-dir is the directory you want to add..
Save the . bash_profile file..
Restart your terminal..

How do I add add usr local Go bin to the PATH environment variable?

Install and Set the Environment Variable Path for Go in Kali....
Navigate to downloaded folder..
Extract the downloaded file using — tar -C /usr/local/ -xzf [Downloaded File Name].
Add variables for go usign in ~/.bashrc..
nano ~/.bashrc..