title: Why emacsclient can't find socket after executing 'emacs --daemon'
body: <p>It is so confusing that emacsclient said it can't find socket just after executing <code>emacs --daemon</code> in bash:</p>
  
  <pre><code>$ ps aux | grep emacs
  shiangro         1744   0.0  0.0  2432784    604 s000  S+    1:03下午   0:00.00 grep emacs
  $ /usr/local/bin/emacs --daemon
  ("emacs")
  Starting Emacs daemon.
  Restarting server
  $ /usr/local/bin/emacsclient -t
  emacsclient: can't find socket; have you started the server?
  To start the server in Emacs, type "M-x server-start".
  emacsclient: No socket or alternate editor.  Please use:
  
      --socket-name
      --server-file      (or environment variable EMACS_SERVER_FILE)
      --alternate-editor (or environment variable ALTERNATE_EDITOR)
  </code></pre>
  
  <p>I have this settings in my .emacs:</p>
  
  <pre><code>(server-start)
  (setq server-socket-dir "~/.emacs.d/server")
  </code></pre>
  
  <p>and it works,the server file <code>~/.emacs.d/server/server</code> was just there,but emacsclient say it can't find socket,so annoying that I have to tell him the socket file using the <code>-s</code> option.</p>
  
  <p>I find this thorny problem while I want let emacs runing as a daemon after everytime rebooting(start) systerm by using crontab's <code>◎reboot</code> special strings. </p>
  
  <p>In this case ,cron successfully started the emacs server and the server file <code>~/.emacs.d/server/server</code> was also there, but later when I started a terminal and tried to <code>emacsclient -t</code> ,it failed and complained can't find socket file!</p>
  
  <p>Although I can bypass this problem by using <code>-s ~/.emacs.d/server/server</code> everytime I excute emacsclient,or alias emacsclient as <code>emacsclient -s ~/.emacs.d/server/server</code> ,but is ther a better way to comfort my heart?</p>
  
  <p><strong>Backgroud:</strong></p>
  
  <p>system: Mac OS X 10.9.2</p>
  
  <p>emacs: GNU Emacs 24.3.1 installed by homebrew</p>