1

I have a very odd problem when Emacs daemon is started by the system. Currently, I work on:

Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.36, cairo version 1.17.6) of 2023-01-03

After login in, I have to manually execute: emacs --daemon in the terminal. Then, Eamcs and packages work correctly. Starting daemon every time I log in is a little annoying, so I tried to automate it. I tried two methods:

  • startup script (Session and Startup on Manjaro) where I put emacs --daemon or
  • enabling a emacs.service run via systemd for a specific user.

For reasons I can't explain, packages do not work when the daemon is run by system. Two examples are AUCTeX and LSP. The first cannot see my custom LaTeX modules and does not even run latexmk. The latter is supposed to ask about project settings, which does not happen.

I checked *Messages* in all cases: running a standalone instance, starting a daemon from terminal, and finally when a daemon is started by the system, in all cases all init files get executed as expected.

When the daemon is running, I open a new frame with emacsclient -c -a emacs.

I wonder what may cause this issue and how I could debug it.

2
  • 2
    Do M-x getenv PATH in both terminal and script scenarios. If the results are different this will go some way to answering yr question. Jun 19, 2023 at 16:18
  • @FranBurstall I tried to look for differences between scenarios and did not recognise any differences. I also opened the shells and run printenv to compare environmental variables. The Peder Klingenberg'a answer works, though. Thanks
    – Celdor
    Jun 20, 2023 at 19:58

1 Answer 1

4

I have had similar issues in the past, and they have always been due to differences in the environment between my interactive shell and the startup scripts.

I solved this by ensuring Emacs is always started from a shell that has been initialized as interactive. So instead of running emacs --daemon from the startup sequence, I run zsh -ic 'emacs --daemon'. (or bash -ic 'emacs --daemon' on machines where I run bash as the shell.)

1
  • Changing emacs --daemon to bash -ic 'emacs --daemon' solved my problem. Thanks for explanation
    – Celdor
    Jun 20, 2023 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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