Coco
Coco

Reputation: 81

Centos 7.6 emacsclient can't find socket

I followed the instructions

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-unit_files

create a emacs.service under /etc/systemd/system/like this

Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/

[Service]
Type=forking
ExecStart=/home/hye/bin/emacs --fg-daemon
ExecStop=/home/hye/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=always

[Install]
WantedBy=default.target

then I execute:

systemctl daemon-reload
systemctl start emacs.service

the emacs.service launched successfully

However when I run emacsclient -t in terminal, it shows:

emacsclient: can't find socket; have you started the server?

I find that if I switch to root and run emacsclient -t in terminal, it works well.

In fact, host name is /tmp/emacs0/server, but I can't access it since it's owner is root.

emacsclient -t -s /tmp/emacs0/server
emacsclient: can't stat /tmp/emacs0/server: Permission denied
emacsclient: error accessing socket "/tmp/emacs0/server"

I have tried to add User option in emacs.service, like this

[Service]
User=hye
Group=hye
Type=forking

but systemctl can't start this service, it is always failed.

I have also tried to put emacs.service under ~/.config/systemd/user/

but centos 7 doesn't support systemctl --user.

system information:

Centos 7.6
Emacs-26.1 manually installed

Any advice would be appreciated!

Upvotes: 1

Views: 883

Answers (1)

John Carter
John Carter

Reputation: 470

I had the same problem....

..it came down to I was using emacs-snapshot for emacs in

   update-alternatives --display emacs

..and a different version for emacsclient

Set it to the same version and then Good Things happened.

sudo update-alternatives --set emacsclient /usr/bin/emacsclient-snapshot

Upvotes: 2

Related Questions