Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting environment variables for Sublime Text on OSX desktop

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!

like image 876
alexrogers Avatar asked Sep 23 '14 12:09

alexrogers


1 Answers

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 icon

More about .bash_profile and .bashrc

like image 84
Mikko Ohtamaa Avatar answered Sep 30 '22 13:09

Mikko Ohtamaa