Setting environment variables for Sublime Text on OSX desktop

最后都变了- 提交于 2019-12-10 13:14:43

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/25994666/setting-environment-variables-for-sublime-text-on-osx-desktop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!