I'd like to be able to access my JAVA_HOME variable that has been set in my .bash_profile from within my sublime text build. When I build I get the following error.
Error: JAVA_HOME is not defined correctly. We cannot execute ....
This is obviously because ST2 doesn't read in my bash profile. Is there any hack around for this?
Thanks!
On UNIX child processes inherit the environment of the parent process. In this case, Sublime Text is not launched through a process chain which would include bash shell which in turn is reading its profile file.
.bash_profile is usually executed on shell login. Depending on your operating system it is not executed when you enter to your desktop environment. Thus, the environment variables are not avaiable.
Workarounds
Put environment variables to a file which is read on the computer boot always (no idea which file unless you tell your operating system) (e.g. lanchd.conf for OSX GUI applications or /etc/profile on Linux)
Modify your dekstop launcher icon
Put hardcoded paths to your build file
Launch Sublime Text using
subl
alias from your bash shell instead of desktop iconMore about .bash_profile and .bashrc