Subject: emacsclient and ssh on MacOS X

From: Steven Ihde <[email-masked]>
Date: Mon, 12 Jul 2010 13:38:21 -0700

I experienced this problem too.  I found that in my case the problem  
was caused by the setting of $TMPDIR on OS X.

When logging in at the desktop, $TMPDIR is set by launchd to some  
directory under /var/folders.  This doesn't happen when logging in via  
ssh.  Thus, emacsclient on an ssh session is unable to find a server  
started under a desktop session, because they communicate through a  
unix socket located under $TMPDIR.

To fix this, add something like the following to your .profile  
or .bashrc so it is executed when logging in via ssh:

if [ -z "$TMPDIR" ]; then
   export TMPDIR=`getconf DARWIN_USER_TEMP_DIR`
fi

This will set TMPDIR to the same per-user directory as when logging in  
on the desktop.

This fixed the problem for me.