问题
When running sublime from desctop it does not see my PERL5LIB environment variable. When running it from terminal - everithing is OK. I set my variables in .bashrc and .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'
this makes trouble with linting and build system - I can not link and build becase of perl does not see libraries.
How to fix env variable?
回答1:
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
or do small script:
#!/bin/bash
source ~/.bashrc
/opt/sublime_text/sublime_text
来源:https://stackoverflow.com/questions/28940230/sublime-does-not-see-env-variables