In my .bashrc, I define TMPDIR=${HOME}/tmp so temporary files are under my encrypted $HOME. emacs, invoked from the launcher, doesn't see this definition, but emacsclient, invoked from a shell does.

So far, I know that emacs (after (server-start)) opens a socket in '/tmp', 'emacsclient' tries to communicate with 'emacs' over a socket in '${HOME}/tmp', and does very poorly. How can I presuade the launcher (via emacsclient.desktop?) to pass the right value for TMPDIR?


Try putting the variable definition in .profile instead of .bashrc. The latter has a statement near the top that causes it to exit very early when executed by a non-interactive shell. Log out and back in to see whether it works.

Also don't forget to add export like this:

export TMPDIR="$HOME/tmp"

If that doesn't work, modify the launcher (it's in /usr/share/applications) so that its Exec line says:

Exec=sh -c 'TMPDIR="$HOME/tmp" emacs'
  • Putting the definition in ~/.profile worked! Thanks. It's a much better solution. – waltinator Oct 6 '11 at 6:08

I guess I can't pass my TMPDIR in to the emacs server-start function, so I guess I'll have to make emacsclient use /tmp to hold the socket.

In my .bashrc:

export EDITOR="env TMPDIR=/tmp emacsclient"
export VISUAL="env TMPDIR=/tmp emacsclient"

but that seems sub-optimal. Any suggestions?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.