Setting environment variables

Hello!


I was wondering whether there is a simple way to set environment variables on MacOS - similar to Linux where variables defined in .bashrc get picked up by the operating system (and desktop manager) and the 'Environment Variables' settings menu in Windows. I would like it to work user-wide, not only when I open a terminal.


I found this one: Environment variables - Apple Community , but the link in there doesn't work anymore - and also the suggested answer with a launch daemon does sound rather complicated for this seamingly simple use case.


This one also doesn't work: https://phoenixnap.com/kb/set-environment-variable-mac (bash-profile / zsh profiles only work inside terminals but not on the system itself).


Others such as here refer to a ~/.MacOSX folder, which does not exist on my MacOS (latest version at time of writing, i.e., Ventura 13.4).


This https://stackoverflow.com/questions/603785/environment-variables-in-mac-os-x talks about using launchctl setenv PATH $PATH, but that does not persist over reboots, and launchctl config system path $PATH only allow to set the PATH variable.


This link also doesn't exist anymore: https://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html


I'm a bit surprised that it is so hard to set up the environment variables as MacOS user. it sounds like a very common thing to do, especially as developer? Does anyone know how to do this - and, equally interesting, what are the design choices in MacOS that lead it to be so difficult? Thanks for looking with me for any solution that works ;)


Posted on Jun 6, 2023 12:52 PM

Reply

Similar questions

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Setting environment variables

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.