Sample Header Ad - 728x90

How to set PATH for all applications on a per-user basis?

7 votes
0 answers
2506 views
I'm looking for a way to set the PATH environment variable for **all** applications that **I** (and only I) run under macOS (version 14 / Sonoma at the time of writing.) That sounds like it *ought* to be straightforward, but it seems not to be, and I haven't found any current, working instructions on how to do it. To be clear, here are three things that I **do** know how to do, that there are (some) decent instructions out there for, and that are **not** what I'm asking about now: 1. Set the environment variables for a shell (e.g. zsh, bash, etc) and by extension applications that are launched *from* that shell. All the normal UNIX techniques and configuration files work fine for this. If I set a variable in my ~/.zshrc and then start any app I want (GUI or not) from within zsh, it works as expected. 2. Set an environment variable which is **not** PATH for apps *not* launched from a shell. There are several ways of doing that using launchctl setenv, and they're dirty and hackish, but they work. I've written up one way of doing that at Add system-wide environment-variables in MacOS Ventura . However, macOS appears to have special-case handling for PATH that's different from other environment variables. 3. Change the PATH variable for **all** users: I can add entries to /etc/paths or /etc/paths.d/ but then those affect everybody, which is actively unhelpful on a multi-user system, especially since I want to include some directories that other users can't even access. So, those out of the way, does anyone know of a command, configuration file, settings option, magic incantation, etc. that will let me set the PATH variable given to any process I launch, no matter how I launch it (e.g as a login item, from Finder, from the dock, whatever) that doesn't involve making a system-wide change and messing up other users?
Asked by Eric Anderson (191 rep)
Oct 6, 2023, 05:35 PM
Last activity: Oct 6, 2023, 06:41 PM