When I don't start it from a terminal, Emacs 24.5.1 (compiled from source) doesn't pick up my environment variables. In particular, to "import" the environment variables from shell, I have in my
(setq exec-path-from-shell-variables (quote ("PATH" "MANPATH" "INFOPATH" "C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH" "LIBRARY_PATH" "LD_LIBRARY_PATH" "SSH_AUTH_SOCK"))) (exec-path-from-shell-initialize)
and to provide my unlocked private key to
ssh using GNOME Keyring's "
gnome-keyring-daemon) I have in my
.bashrc (my user shell is
if [ -n "$DESKTOP_SESSION" ];then eval $(gnome-keyring-daemon --start --components=ssh) export SSH_AUTH_SOCK fi
But upon doing any remote-related task (e.g.,
pull) in Magit I get the error
fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
*magit-process* buffer, which means that Emacs does not see my unlocked private key and, hence, that Emacs is not using the socket provided by
SSH_AUTH_SOCK, because the same remote-related
git commands run without any problems in a terminal.
I've checked in
SSH_AUTH_SOCK has the same value in Emacs as it does in an outside terminal with
bash. Also, when I start Emacs from a terminal (in X or a TTY), all the environment variables are picked up and there are no problems. I know when run in a terminal, Emacs inherits the environment variables from the shell. My question is why aren't my environment variables (which are apparently "imported" correctly into Emacs by
exec-path-from-shell-variables) used by Emacs when I don't start it from a terminal? The same setup has been working on my other machine for several years with Emacs 24.3, but I doubt the culprit could be the newer Emacs version.
Edit: My operating system is Trisquel 7.0 which is based on Ubuntu 14.04 GNU/Linux. I usually use LXDE, but the problem is there with other desktop environments too. Outside a terminal I start Emacs by pressing
Alt+F2 (Run) and entering
emacs. In a terminal I start Emacs by entering
emacs. My environment variables are set in
~/.bashrc. I am aware of the intricacies of login and non-login shells (interactive or not) and I've checked that my
~/.bashrc is run regardless of how I log in (e.g., in X to a desktop environment or window manager, in a TTY, or through