Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't reconnect to the daemon #14

Open
danielkrizian opened this issue Feb 20, 2019 · 4 comments
Open

Can't reconnect to the daemon #14

danielkrizian opened this issue Feb 20, 2019 · 4 comments

Comments

@danielkrizian
Copy link

I have started emacs (v26.1) server:

$ emacs --daemon

I connected using

$ emacsclient -t

From within emacs, well spacemacs, I restarted the daemon SPC q r, which executed dotspacemacs/resume-emacs-resume-layouts tied to restart-emacs.el.

After daemon restarted, I see the process in htop running but can't reconnect to it.

$ htop

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command                                                                                                                                    
 6579 dk         20   0  232M  164M  9664 S  0.0  0.3  0:05.46 /opt/conda/bin/emacs --daemon=server --resume-layouts --restart-emacs-desktop /tmp/restart-emacs-desktopOpor7P
 6578 dk         20   0 77948 11348 10024 S  0.0  0.0  0:00.00 /opt/conda/bin/emacs --daemon=server --resume-layouts --restart-emacs-desktop /tmp/restart-emacs-desktopOpor7P  

I was expecting to see the message Emacs daemon restarted! Use '%s -nw -s %s %s' to reconnect to it pop up in my bash terminal, but it does not appear.

How can I reconnect to the server? I tried this:

$ emacsclient --s server -t
emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".
emacsclient: error accessing socket "server"
$ 

Can I use the /tmp/restart-emacs-desktopOpor7P information somehow?

@iqbalansari
Copy link
Owner

Hi @danielkrizian, this might happen if Emacs is not able to start successfully in the daemon mode, possibly due to some bug in init file, could try running /opt/conda/bin/emacs --daemon=server --resume-layouts --restart-emacs-desktop <desktop file> yourself, this might given some hint as to what went wrong. As to using the information in desktop file, you use the function restart-emacs--restore-frames-using-desktop to load frames from the desktop file, do something like (restart-emacs--restore-frames-using-desktop "<desktop file>")

@danielkrizian
Copy link
Author

Hi @iqbalansari, thanks, I tried running as you suggested, still don't get the expected behavior, i.e. don't get the expected message Emacs daemon restarted! Use '%s -nw -s %s %s' to reconnect to it and the terminal does not show the restored emacs buffers from previous session.

Step by step what I did:

$ emacs --daemon
$ emacsclient -t

In the open Spacemacs terminal session that pops up, SPC q r tied to dotspacemacs/resume-emacs-resume-layouts.
I am now back in the terminal.

$ htop
  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command                                                                                                                                                                                
23102 dk         20   0  189M  124M  8776 S  0.0  0.2  0:03.47 /opt/conda/bin/emacs --daemon=server --resume-layouts --restart-emacs-desktop /tmp/restart-emacs-desktopdBkj0J                                                                  
22953 dk         20   0  231M  166M  8768 S  0.0  0.3  0:04.78 /opt/conda/bin/emacs --daemon=server --resume-layouts --restart-emacs-desktop /tmp/restart-emacs-desktopdBkj0J

$ /opt/conda/bin/emacs --daemon=server --resume-layouts --restart-emacs-desktop /tmp/restart-emacs-desktopdBkj0J
Loading /home/dk/dotfiles/.spacemacs.d/init.el (source)...
Loading /home/dk/dotfiles/.spacemacs.d/init.el (source)...done
Loading /home/dk/dotfiles/.emacs.d/custom.el (source)...
Loading t-mouse...
Loading t-mouse...done
Loading xt-mouse...
Loading xt-mouse...done
Loading /home/dk/dotfiles/.emacs.d/custom.el (source)...done
spacemacs buffer error: (beginning-of-buffer)
Eshell virtualenv support initialized.
Spacemacs is ready.
No desktop file.

$

Note the last command prompt ($). At this point I would have expected message in the terminal saying Emacs daemon restarted! Use '%s -nw -s %s %s' to reconnect to it. Instead I am back in the terminal and see the third emacs process running in htop, without being able to attach to it and see the usual emacs terminal environment buffers.

$ htop
  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command                                                                                                                                                                                
23102 dk         20   0  189M  124M  8776 S  0.0  0.2  0:03.47 /opt/conda/bin/emacs --daemon=server --resume-layouts --restart-emacs-desktop /tmp/restart-emacs-desktopdBkj0J                                                                  
22953 dk         20   0  231M  166M  8768 S  0.0  0.3  0:04.78 /opt/conda/bin/emacs --daemon=server --resume-layouts --restart-emacs-desktop /tmp/restart-emacs-desktopdBkj0J
22952 dk         20   0 74812 11620 10276 S  0.0  0.0  0:00.01 /opt/conda/bin/emacs --daemon=server --resume-layouts --restart-emacs-desktop /tmp/restart-emacs-desktopdBkj0J

@iqbalansari
Copy link
Owner

This seems like the problematic error

spacemacs buffer error: (beginning-of-buffer)

It seems this error is preventing Emacs init from completely running and thus restart-emacs's startup hook which prints this message is never getting a chance

@iqbalansari
Copy link
Owner

Hello @danielkrizian, any update on this? Is this still happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants