magit / with-editor

Use the Emacsclient as the $EDITOR of child processes
http://magit.vc/manual/with-editor
GNU General Public License v3.0
188 stars 44 forks source link

magit fails to locate emacsclient at /usr/local/bin/emacsclient #65

Closed zenny closed 5 years ago

zenny commented 5 years ago

Hi,

I compiled emacs 26.2 in ubuntu (still in 14.04) to use with doom-emacs and it reports that it cannot locate emacsclient

Warning (with-editor): Cannot determine a suitable Emacsclient

Determining an Emacsclient executable suitable for the
current Emacs instance failed.  For more information
please see https://github.com/magit/magit/wiki/Emacsclient.
Warning (ox-pandoc): Pandoc version number can not be retrieved.

in spite of

$ which emacsclient
/usr/local/bin/emacsclient

$ emacsclient -v
emacsclient 26.2

I could not locate any reason why magit failed to locate the emacsclient which was installed on the default location. Any clues?

Cheers,

tarsius commented 5 years ago

For more information please see https://github.com/magit/magit/wiki/Emacsclient.

Did you do that and also follow the links at the bottom of that page?

zenny commented 5 years ago

@tarsius, /usr/local/bin where the emacsclient is located is defined in my $PATH as evident from:

$ echo $PATH
/home/zenny/.asdf/shims:/home/zenny/.asdf/bin:/home/zenny/.local/share/umake/bin:/home/zenny/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/brlcad/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/zenny/.fzf/bin

Fyi, the emacs is also in v26.2 as explained in 2 at the bottom of the link you sent.

$ emacs --version
GNU Emacs 26.2
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Anything else that I missed to do? If so, what could be that?

Thanks and cheers, /z

tarsius commented 5 years ago

Please do this: https://magit.vc/manual/with-editor/Debugging.html.

zenny commented 5 years ago

Here is the output:

$ cat magit-debug.output 
with-editor: /home/zenny/.emacs.d/.local/packages/elpa/with-editor-20190511.1157/with-editor.el
emacs: /usr/local/bin/emacs (26.2)
system:
  system-type: gnu/linux
  system-configuration: x86_64-pc-linux-gnu
  system-configuration-options: 
server:
  server-running-p: t
  server-process: #<process server>
  server-use-tcp: nil
  server-name: server
  server-socket-dir: /tmp/emacs1002
    server
  server-auth-dir: /home/zenny/.emacs.d/.local/cache/server/
    WARNING: not an accessible directory
with-editor-emacsclient-executable:
 value:   nil (nil)
 default: nil (nil)
 funcall: nil (nil)
path:
  $PATH: "/home/zenny/.asdf/shims:/home/zenny/.asdf/bin:/home/zenny/.local/share/umake/bin:/home/zenny/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/brlcad/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/zenny/.fzf/bin"
  exec-path: (/home/zenny/.asdf/shims /home/zenny/.asdf/bin /home/zenny/.local/share/umake/bin /home/zenny/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /usr/brlcad/bin /usr/lib/jvm/java-8-oracle/bin /usr/lib/jvm/java-8-oracle/db/bin /usr/lib/jvm/java-8-oracle/jre/bin /home/zenny/.fzf/bin /usr/local/libexec/emacs/26.2/x86_64-pc-linux-gnu/)
  with-editor-emacsclient-path:
    /home/zenny/.asdf/shims (t)
    /home/zenny/.asdf/bin (t)
    . (t)
    /home/zenny/.local/share/umake/bin (t)
    /home/zenny/bin (t)
    /usr/local/sbin (t)
    /usr/local/bin (t)
      /usr/local/bin/emacsclient (nil)
    /usr/sbin (t)
    /usr/bin (t)
    /sbin (t)
    /bin (t)
    /usr/games (t)
    /usr/local/games (t)
    /usr/brlcad/bin (t)
    /usr/lib/jvm/java-8-oracle/bin (t)
    /usr/lib/jvm/java-8-oracle/db/bin (nil)
    /usr/lib/jvm/java-8-oracle/jre/bin (t)
    /home/zenny/.fzf/bin (t)
    /usr/local/libexec/emacs/26.2/x86_64-pc-linux-gnu/ (t)

The emacsclient binary is where it should be:

$ which emacsclient 
/usr/local/bin/emacsclient

Thanks.

tarsius commented 5 years ago
    /usr/local/bin (t)
      /usr/local/bin/emacsclient (nil)

Instead of nil this should show the version. That's weird--above you showed how you got the version of that. Do it very explicitly: /usr/local/bin/emacsclient --version.

zenny commented 5 years ago
$ /usr/local/bin/emacsclient --version
emacsclient 26.2

Even tried with explicitly appending

(add-to-list 'exec-path "/usr/local/bin")

to $HOME/.emacs.d/init.el ('bin/doom refresh' was also executed afterwards), but with the same message.

tarsius commented 5 years ago

This is how the version is determined:

(defun with-editor-emacsclient-version (exec)
  (let ((default-directory (file-name-directory exec)))
    (ignore-errors
      (cadr (split-string (car (process-lines exec "--version")))))))

(with-editor-emacsclient-version "/usr/local/bin/emacsclient")

In your case that apparently returns nil. Change the definition until you know what is going wrong. Start by removing the ignore-errors.