I accidentally overwrote my .profile file and I believe deleted my environment variables. To be honest, I don't really understand how the operating system handles environment variables. My rough understanding is that there are configuration files like .profile which the operating system looks at, or runs, automatically and sets the environment variables that way. But how does the system know which config files to run? Are there default config files? Is .profile a default config file in OS X? If .profile is one of these default config files, is there a way for me to retrieve it or else the environment variables that it sets by default. What are the default values for .profile in OS X?
MacOS – What environment variables are set in .profile for OS X
bashmacos
Related Question
- MacOS – In OSX Yosemite, why can I set many environment variables for GUI apps, but cannot set the specific variable PATH
- MacOS – Shell set environment variables for command
- Interaction between profiles of Terminal.app and environment variables
- MacOS – Setting environment variables (TEXINPUTS) in El Capitan
- Open Terminal with Predefined Environment Variables – macOS Terminal Setup
Best Answer
In your terminal that still has the variables write
printenv > with_profile.txt
. This will dump all available variables intowith_profile.txt
. Open a new terminal window and writeprintenv > without_profile.txt
.Start python and write:
That should print the set of missing variables one by one.
P.S.
~/.profile
is not there by default (not on Mavericks, Yosemite and El Capitan for sure). Hence it's possible that you overwrote nothing, unless you had created the file yourself a long ago.