macOS Big Sur - set env vars for GUI apps?
The following worked for me to get an environment variable to be accessible from a GUI app (SwiftBar).
I created a plist file (eg; com.example.set-env-vars.plist) in ~/Library/LaunchAgents/ with the following contents:
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;setenv.MY_VARS&lt;/string&gt;
  &lt;key&gt;ProgramArguments&lt;/key&gt;
  &lt;array&gt;
    &lt;string&gt;sh&lt;/string&gt;
    &lt;string&gt;-c&lt;/string&gt;
    &lt;string&gt;launchctl setenv MY_VAR my_value&lt;/string&gt;
  &lt;/array&gt;
  &lt;key&gt;RunAtLoad&lt;/key&gt;
  &lt;true/&gt;
  &lt;key&gt;KeepAlive&lt;/key&gt;
  &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;

Then I rebooted for it to take effect. I suspect logging out and logging back in may be adequate, since stuff in ~/Library/LaunchAgents/ should be applied at login.
If anyone can improve this answer, I'd love to know why this works but running launchctl setenv MY_VAR my_value from a terminal does not.
Swap out MY_VAR and my_value as needed. Note, I'm not sure whether this would allow you to do something like launchctl setenv PATH &quot;/usr/local/bin:$PATH&quot;, as I'm not sure whether $PATH would exist or expand properly.