Everywhere All articles Download Buy — $19

Where apps hide your files

Where macOS builds your PATH

Updated 2026-10-28 · 6 min read

PATH is built at start-up: your shell files, plus the system list that path_helper reads from /etc/paths and /etc/paths.d. Add your own folders in ~/.zprofile, and check the result with one command.

Where PATH comes from

PATH is not stored in one file. Your shell builds it at start-up, and for a zsh login shell (the kind every Terminal tab starts) the files run in this order, per man zsh:

~/.zshenv        every zsh shell
/etc/zprofile    login shells: runs path_helper, which reads
                   /etc/paths      (the base list)
                   /etc/paths.d/*  (one or more folders per file)
~/.zprofile      login shells
/etc/zshrc       interactive shells
~/.zshrc         interactive shells

The system's list is put together by a small tool called path_helper. The ~ files are your own, in your home folder. To add a folder for yourself, edit ~/.zprofile. To see the result, which changes nothing:

echo $PATH | tr ':' '\n'

That prints one folder per line, in the order the shell searches them.

The system part: /etc/paths and /etc/paths.d

/etc/paths is a plain text file with one folder per line. On the Mac used for this guide it holds six:

/usr/local/bin
/System/Cryptexes/App/usr/bin
/usr/bin
/bin
/usr/sbin
/sbin

/etc/paths.d/ holds extra files, one folder per line each. Here it contains 10-cryptex and 100-rvictl, and the exact set differs between macOS versions and with the tools you have installed. Apple's open-source path_helper sorts the files by their number prefix, then by name, so 10- comes before 50- and 100-. Both locations are owned by root.

The man page for path_helper (man path_helper) says it reads /etc/paths first, then every file in /etc/paths.d. It also says it should not be run directly: the system calls it for you from /etc/zprofile for zsh and /etc/profile for bash, as both files on the Mac used for this guide show.

One result of this surprises people. Running path_helper with a made-up /custom/bin already in PATH, on the Mac used for this guide, put the system folders first and /custom/bin last in its output. So a PATH line in ~/.zshenv is re-sorted behind the system folders in a login shell, because ~/.zshenv runs before /etc/zprofile. A line in ~/.zprofile or ~/.zshrc runs afterwards and keeps its place. Homebrew's installer uses ~/.zprofile for zsh, which makes it the usual place for PATH lines.

Add a folder to PATH in zsh

Back up the file, edit, check, and know how to undo it:

  1. Back up: cp ~/.zprofile ~/.zprofile.backup (if the file does not exist, skip this and create it with touch ~/.zprofile).
  2. Open it: open -e ~/.zprofile
  3. Add one line at the bottom. To search your folder first:
export PATH="$HOME/.local/bin:$PATH"

To search it last instead, put $PATH first: export PATH="$PATH:$HOME/.local/bin". Replace the folder with your own. Keep $PATH in the line, or you will replace the whole list and commands such as ls will stop being found in that shell.

  1. Save, then open a new Terminal tab and run the echo $PATH command above.
  2. Undo: cp ~/.zprofile.backup ~/.zprofile, or delete your line.

If a broken PATH leaves you without basic commands, call them by full path, for example /usr/bin/open -e ~/.zprofile, and fix the line.

The same line in ~/.zshrc also works in Terminal. The difference: ~/.zshrc runs for every interactive shell, so a shell started inside another one adds the folder a second time. The duplicates are harmless but make PATH long.

Add a folder for every user

To add a folder system-wide, man path_helper points at /etc/paths.d: a file there with one folder per line is picked up for every user and every new shell. Creating one needs sudo, for example sudo nano /etc/paths.d/50-mytools (on recent macOS nano opens pico, which works the same way) with a single line such as /opt/mytools/bin. Check the folder exists first. To undo, delete only that one new file, for example sudo rm /etc/paths.d/50-mytools. Most people do not need this, and a personal line in ~/.zprofile is easier to undo. Do not edit /etc/paths itself, or the files Apple ships in /etc/paths.d: they need sudo, apply to every account, and a mistake there can break every account's shells. If you ever must, copy the file first with sudo cp /etc/paths /etc/paths.backup.

Which program will run?

When a command runs the wrong version, ask the shell what it finds, in order:

which -a python3
type -a node

The first result is the one that runs. That is how you spot a Homebrew copy hiding behind an Apple one, or the reverse.

Homebrew and other installers

Homebrew installs to /opt/homebrew on Apple silicon. When its installer finishes, it prints the commands that add an eval "$(/opt/homebrew/bin/brew shellenv ...)" line to ~/.zprofile for zsh, or to ~/.bash_profile for bash. Copy what it prints for your Mac rather than typing it from a guide. Many installers (version managers such as nvm, language toolchains) append a block to your shell files the same way, so look for stray duplicates at the bottom of ~/.zprofile and ~/.zshrc if PATH has grown long.

/usr/local/bin is already first in /etc/paths on every Mac, which is why an Intel Homebrew (which lives in /usr/local) works without any edit while /opt/homebrew/bin needs the shellenv line. The Mac used for this guide has both Homebrew folders.

If you use bash

Bash reads /etc/profile, which also runs path_helper, then the first of ~/.bash_profile, ~/.bash_login or ~/.profile. Put the same export PATH=... line in ~/.bash_profile.

Apps that ignore your shell files

Apps opened from the Dock or Finder do not start from your terminal, so they do not read ~/.zprofile or ~/.zshrc. An editor or tool launched that way may not find a command that works fine in Terminal. Starting the app from Terminal passes your shell's PATH to it, and many apps have a setting for the path of a tool. If this keeps happening, check the app's own documentation, because the right fix varies by app.

Why searching misses these files

/etc is hidden from Finder, the files have no extension, and .zprofile and .zshrc start with a dot. path_helper itself lives in /usr/libexec, another folder Finder does not show.

Finding the files next time

Type paths.d into Everywhere to land on the folder in /private/etc and see which files are in it, or type zprofile to find your own start-up file and any .backup copies you made. The scan includes system folders and hidden files in your home folder, and names only are searched, so it will not show the lines inside. ⌘↵ reveals a result in Finder.

Common questions

Where is PATH set on a Mac?

The system list is in /etc/paths and /etc/paths.d/, combined by path_helper, which /etc/zprofile runs for zsh login shells. Your own additions go in ~/.zprofile (or ~/.zshrc).

How do I add a folder to PATH in zsh?

Add export PATH="$HOME/.local/bin:$PATH" (with your own folder) to ~/.zprofile, then open a new Terminal tab. Back the file up first, and keep $PATH in the line.

What is /etc/paths.d on a Mac?

A folder of small text files, each listing one path per line, that path_helper appends to PATH for every user, in order of each file's number prefix. Apple and some installers put files there; adding one needs sudo.

How do I see my current PATH?

Run echo $PATH | tr ':' '\n' in Terminal. It prints one folder per line in the order they are searched.

Find any file before you finish typing

Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.

Version 2.20.3 · macOS 13+ · 4.7 MB · notarised

Related

© 2026 Caretopia Network Private Limited Everywhere for Mac Buy a licence Articles Privacy Support