Sublime 看不到环境变量

Sublime does not see env variables

当 运行 从 desctop 升华时,它看不到我的 PERL5LIB 环境变量。 当 运行 它来自终端时 - 一切正常。 我在 .bashrc 和 .bash_profile.

中设置了我的变量
import os
>>> os.environ['SHELL']
'/bin/bash'
>>> os.environ['PERL5LIB']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "./os.py", line 676, in __getitem__
KeyError: 'PERL5LIB'

这会给 linting 和构建系统带来麻烦 - 我无法 link 构建,因为 perl 看不到库。

如何修复环境变量?

Bad news:

The Ubuntu desktop session is no longer affected by .profile. Additionally bash doesn't parse .profile if either .bash_profile or .bash_login exists.

You can work around:

Launching desktop application with an environment variable

You can add an environment variable to an application by editing its .desktop file. For example, to run "digiKam" with the environment variable APPMENU_DISPLAY_BOTH=1, find the corresponding digikam.desktop file and add the setting of the variable, via the env command, to the entry "Exec":

Exec=env APPMENU_DISPLAY_BOTH=1 digikam -caption "%c" %i

或者做小脚本:

#!/bin/bash
source ~/.bashrc
/opt/sublime_text/sublime_text