So when I invoke emacs from the terminal, all my environment variables are loaded correctly from .bashrc. However, when I load emacs from the Ubuntu Application menu (by invoking the /usr/share/applications/emacs24.desktop) it loads no environment variables. Can I adjust the desktop setting to do so?

1 Answer 1


.bashrc is not the right place to define environment variables, as you've discovered. This file is only read when you start an interactive shell (specifically, only when you start an interactive instance of bash, not of other shells). The environment is then inherited by the processes started from that shell (each process has its own environment, inherited from its parent process). So if you start a program directly from the GUI, it never had a chance to see these environment variables.

Define environment variables in ~/.profile or in ~/.pam_environment. Both files are read when you log in.

For more information, see Alternative to .bashrc and What's the best distro/shell-agnostic way to set environment variables?


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .