在OSX桌面上为Sublime Text设置环境变量 [英] Setting environment variables for Sublime Text on OSX desktop
问题描述
我希望能够从高级文本构建中访问在.bash_profile中设置的JAVA_HOME变量.构建时,出现以下错误.
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.
错误:未正确定义JAVA_HOME.我们无法执行....
Error: JAVA_HOME is not defined correctly. We cannot execute ....
这显然是因为ST2不在我的bash个人资料中读取.对此有什么可笑之处吗?
This is obviously because ST2 doesn't read in my bash profile. Is there any hack around for this?
谢谢!
推荐答案
在UNIX上,子进程继承了父进程的环境.在这种情况下,Sublime Text不会通过流程链启动,该流程链将包括bash shell,而bash shell会依次读取其配置文件.
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通常在shell登录时执行.根据您的操作系统,当您进入桌面环境时,它不会执行.因此,环境变量不可用.
.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.
解决方法
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)
修改您的Dekstop启动器图标
Modify your dekstop launcher icon
将硬编码路径放入构建文件
Put hardcoded paths to your build file
使用bash shell中的 subl
别名而不是桌面图标启动Sublime Text
Launch Sublime Text using subl
alias from your bash shell instead of desktop icon
这篇关于在OSX桌面上为Sublime Text设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!