TransWikia.com

emacsclient unable to connect to daemon under snap installation of Emacs

Emacs Asked on September 2, 2021

I am facing with a well know problem, when I try to start emacs --daemon on a remote machine, I am getting following error emacsclient: connect: Connection refused:

$ ps aux | grep -E "[e]macs"  # returns empty
$ emacsclient -t -q doo.py
emacsclient: connect: Connection refused

Warning: due to a long standing Gtk+ bug
https://gitlab.gnome.org/GNOME/gtk/issues/221
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
## ...
Starting Emacs daemon.
Unable to start the daemon.
Another instance of Emacs is running the server, either as daemon or interactively.
You can use emacsclient to connect to that Emacs process.
Error: server did not start correctly
Error: Could not start the Emacs daemon


The way I connect into the remote machine ssh -Y4t user@IP zsh --login -i

I don’t know what can I debug more to handle this or what is the issue. I also have same configuration on a different remote machine where it works without a problem.


Update based on @phils guide(please see in comments) debug in depth.

$ kill -9 $(ps aux | grep -E "[e]macs" | awk '{print $2}')
$ ps aux | grep -E "[e]macs"  # returns empty
$ emacsclient -t -q doo.py
emacsclient: can't find socket; have you started the server?
emacsclient: To start the server in Emacs, type "M-x server-start".

Warning: due to a long standing Gtk+ bug
https://gitlab.gnome.org/GNOME/gtk/issues/221
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.

$ ps aux | grep -E "[e]macs"  # returns empty
netlab    9885 14.1  0.4 464628 67812 ?        Ssl  01:40   0:04 /snap/emacs/296/usr/bin/emacs --daemon
$ kill -9 $(ps aux | grep -E "[e]macs" | awk '{print $2}')
$ ps aux | grep -E "[e]macs"  # returns empty

$ unset ALTERNATE_EDITOR
$ echo $ALTERNATE_EDITOR

$ ls -l /tmp/emacs1002/server
srwx------ 1 netlab netlab 0 Jul 16 01:40 /tmp/emacs1002/server
$ rm -rf /tmp/emacs1002/server
$ ls -l /tmp/emacs1002/server
ls: cannot access '/tmp/emacs1002/server': No such file or directory
$ emacsclient -t
emacsclient: can't find socket; have you started the server?
emacsclient: 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)
$ emacs -Q --daemon

Warning: due to a long standing Gtk+ bug
https://gitlab.gnome.org/GNOME/gtk/issues/221
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
Starting Emacs daemon.
$ ls -l /tmp/emacs1002/server
srwx------ 1 netlab netlab 0 Jul 16 01:42 /tmp/emacs1002/server
$  emacsclient -t
emacsclient: can't find socket; have you started the server?
emacsclient: 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)

One Answer

Thanks to hands up here (https://github.com/tealeg/emacs-snap/issues/1#issuecomment-660462402) and @phils's help on comments

It seems the current snap is https://github.com/alexmurray/emacs-snap

I made a clean installation using Alex Murray's snap (emacs 26.3 from Alex Murray). I verify that emacs --daemon works perfectly fine.


The mistake I made;

When I was facing the error, I believe I I have used following ppa link :-( => sudo add-apt-repository ppa:kelleyk/emacs due to this documentation (https://linuxhint.com/ubuntu_emacs_installation/), which had the socket problem related to emacs --daemon issue I faced.


Correct answer by alper on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP