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

emacsclient cannot open display #224512

Closed
crawford opened this issue Apr 3, 2023 · 6 comments · Fixed by #246008
Closed

emacsclient cannot open display #224512

crawford opened this issue Apr 3, 2023 · 6 comments · Fixed by #246008

Comments

@crawford
Copy link
Contributor

crawford commented Apr 3, 2023

Describe the bug

I have the Emacs daemon enabled on my system (services.emacs.enable = true;). When I log in, I can see that the daemon is running but I am unable to start emacsclient:

$ emacsclient -c
Waiting for Emacs...
*ERROR*: Display :0 can’t be opened

Restarting the daemon fixes the issue. Is the daemon starting too early and missing some variables from Wayland?

Steps To Reproduce

Steps to reproduce the behavior:

  1. Enable emacs daemon (services.emacs.enable = true;)
  2. Log in and try to run emacsclient

Expected behavior

emacsclient starts:

$ emacsclient -c
Waiting for Emacs...

Notify maintainers

@DamienCassou

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.103, NixOS, 22.11 (Raccoon), 22.11.3265.e2c97799da5`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.1`
 - channels(root): `"machines, nixos-22.11, nixos-hardware"`
 - channels(alex): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@DamienCassou
Copy link
Contributor

I'm not the maintainer of this service and I don't use it. I use the Emacs service from home-manager which I recommend: https://rycee.gitlab.io/home-manager/.

@crawford
Copy link
Contributor Author

crawford commented Apr 3, 2023

My apologies. I saw that you were the original author, so I figured you were my best bet.

It looks like home-manager might be avoiding this by (optionally) using socket activation. Something similar might work here, but I'm sure there's a more robust solution. I'll have to dig into it a bit when I have time.

@DamienCassou
Copy link
Contributor

@crawford
Copy link
Contributor Author

Yeah, ordering emacs.service after graphical-session.target seems to have worked. Thanks for the tip. I'm trying to work up a nice way to incorporate that into the service definition. Unfortunately, simply adding the "after" directive doesn't seem to be enough. I'm guessing that's because default.target is reached, or at least initiated, before graphical-session.target. I'm going to keep poking at it over the coming days.

Atemu added a commit to Atemu/nixpkgs that referenced this issue Jul 29, 2023
If emacs starts before the graphical session is initialised, clients won't be
able to open new frames in the session. Start emacs with the graphical session
to avoid this issue.

Fixes NixOS#224512
Atemu added a commit to Atemu/nixpkgs that referenced this issue Jul 29, 2023
If emacs starts before the graphical session is initialised, clients won't be
able to open new frames in the session. Start emacs with the graphical session
to avoid this issue.

Fixes NixOS#224512
@ibizaman
Copy link
Contributor

Wanted to confirm startWithUserSession = "graphical" made this issue go away.

@jys1670
Copy link

jys1670 commented Aug 23, 2023

Same here, "graphical" solution works. It would be nice to see @Atemu's pr merged.

LostAttractor pushed a commit to LostAttractor/nixpkgs that referenced this issue Aug 24, 2023
If emacs starts before the graphical session is initialised, clients won't be
able to open new frames in the session. Start emacs with the graphical session
to avoid this issue.

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

Successfully merging a pull request may close this issue.

4 participants