在OSX桌面上为Sublime Text设置环境变量 [英] Setting environment variables for Sublime Text on OSX desktop

查看:87
本文介绍了在OSX桌面上为Sublime Text设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够从高级文本构建中访问在.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

有关.bash_profile和.bashrc的更多信息

这篇关于在OSX桌面上为Sublime Text设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆