After upgrading to Catalina, I encountered the error below. Seems Xcode was no longer available.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Try the following in your terminal; otherwise, head to https://developer.apple.com/download/more/ and download Xcode manually.
I had issues in Yosemite with IntelliJ always complaining that it couldn’t see my M2_HOME variable, even though I had it in my .bash_profile. Turns out that only works in the terminal.
In any case, this worked — I verified it on my Mac, which runs v10.10.5.
1. Save this plist in ~/Library/LaunchAgents/ as custom.startup.plist
launchctl setenv VARIABLE_NAME1 VARIABLE_VALUE1 | launchctl setenv VARIABLE_NAME2 VARIABLE_VALUE2 | launchctl setenv VARIABLE_NAME3 VARIABLE_VALUE3
2. Log out then back in
3. That's it!