2

I've been seeing this issue for some time now, but I don't know how to debug it.

I start up a emacs instance, using say

emacs foo.tex &

Then I run C-c C-c to compile. A new window pops open, and I see the following:

Warning (server): Unable to start the Emacs server.
There is an existing Emacs server, named "server".
To start the server in this Emacs process, stop the existing
server or call `M-x server-force-delete' to forcibly disconnect it.

This is annoying. I'd appreciate help tracking down the problem.

This seems to be related to the emacs server. The only place I have the emacs server mentioned, as far as I can see, is in my .emacs, which has

;; Enable Synctex
(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-start-server t)

Is this causing a problem, and if so, why? I do not have an emacs server running, as far as I can see.

  • Pardon me for asking the obvious question, but did you try M-x server-force-delete like the warning message said? – nispio Oct 25 '14 at 17:46
  • I didn't, no. I tried it just now, and it gave me the following message: Connection file "/tmp/emacs1000/server" deleted. However, no doubt the problem will appear again. I've been seeing this issue for months. And my machine was last rebooted 11 days ago. – Faheem Mitha Oct 25 '14 at 18:22
  • Did you try to reproduce the problem after you deleted the server? When Emacs tells you how to fix your problem, it is usually worth listening to. ;-) – nispio Oct 25 '14 at 18:23
  • 1
    @nispio yes, the problem is not showing up any longer. I don't like to follow directions when I don't know what they mean. Hang on, let me restart emacs. – Faheem Mitha Oct 25 '14 at 18:26
  • It is not showing up any more. In this instance, anyway. – Faheem Mitha Oct 25 '14 at 18:32
3

TL;DR

Either run M-x server-force-delete to delete any existing servers, or remove the lines which enable TeX-source-correlate-mode from your init file.


From the AUCTeX documentation (found via C-h i):

Upon opening the viewer you will be asked if you want to start a server process (Gnuserv or Emacs server) which is necessary for inverse search. This happens only if there is no server running already. You can customize the variable 'TeX-source-correlate-start-server' to inhibit the question and always or never start the server respectively.

-- User Option: TeX-source-correlate-start-server If 'TeX-source-correlate-mode' is active and a viewer is invoked, the default behavior is to ask if a server process should be started. Set this variable to 't' if the question should be inhibited and the server should always be started. Set it to 'nil' if the server should never be started. Inverse search will not be available in the latter case.

Inverse search, i.e. jumping to the part of your document source in Emacs corresponding to a certain position in the viewer, is triggered from the viewer, typically by a mouse click. Refer to the documentation of your viewer to find out how it has to be configured and what you have to do exactly. In xdvi you normally have to use 'C-down-mouse-1'.

In other words, starting an edit server lets you click a location in your typeset output file and it will jump you to the corresponding location in the source. If this is not a feature you use, or plan to use, then you can simply remove those lines from your init.

The most likely cause of your problem is a lingering server socket that is preventing emacs from starting a new edit server in this emacs process. The most likely cause is that emacs was not shut down properly at some point, and did not have a chance to delete the socket. If you call M-x server-force-delete it should fix all of your problems. Once the old server is deleted, the current emacs process will be free to create its own server socket and things should work as expected.

As long as Emacs is closed properly each time (by C-x C-c or similar) then you should not see this problem again. If Emacs crashes or is force killed in the future, then you may have to manually delete the server again. You could also add the following to your init file to automatically kill any old servers when Emacs is started:

(require 'server)
(server-force-delete)  ;; WARNING: Kills any existing edit server

If you only ever have one instance of Emacs running at a time, this should never cause you any problems. If you open a second instance of Emacs (not just a second frame, but a whole new process) then only the most recent instance will behave as the server.

  • "In other words, starting an edit server lets you click a location in your typeset output file and it will jump you to the corresponding location in the source. If this is not a feature you use, or plan to use, then you can simply remove those lines from your init." Actually, this is a feature that I would definitely like to have, but has not worked for me in the past. But I suppose that is a topic for a different question. – Faheem Mitha Oct 25 '14 at 18:28
  • "If you open a second instance of Emacs (not just a second frame, but a whole new process) then only the most recent instance will behave as the server." So, just to be clear, if I have two different instances, both running synctex, will there be problems, since both syntex instances are trying to run servers? – Faheem Mitha Oct 25 '14 at 18:31
  • @FaheemMitha About your first comment: Actually, this is that question. Solve this problem and you will solve that problem. – nispio Oct 25 '14 at 18:41
  • Yes. Generally speaking you can only have one server running at a time. However, Emacs can run multiple frames under the same process, tied to the same server, and there will be no problems. See the GNU Emacs manual for more on working with frames – nispio Oct 25 '14 at 18:44
  • "Actually, this is that question. Solve this problem and you will solve that problem." So, if I understand you correctly, you are saying the reason that wasn't working was because of a stuck server? – Faheem Mitha Oct 25 '14 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.