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

bug: emacs service needs restart on first login for emacsclient #3443

Closed
2 tasks done
shlevy opened this issue Nov 26, 2022 · 12 comments
Closed
2 tasks done

bug: emacs service needs restart on first login for emacsclient #3443

shlevy opened this issue Nov 26, 2022 · 12 comments
Assignees
Labels
bug triage Issues or feature request that have not been triaged yet

Comments

@shlevy
Copy link

shlevy commented Nov 26, 2022

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

If I try to launch emacsclient from the (gnome) application toolbar on first login, nothing shows up and the logs for emacs.service have:

Nov 26 09:53:24 darter6 bash[2073]: Authorization required, but no authorization protocol specified

If I try emacsclient -c from the shell, I get an error about :0 not being available to open.

Restarting the emacs user service fixes the issue until next login.

Maintainer CC

@tadfisher @DamienCassou

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.0.9, NixOS, 22.11 (Raccoon), 22.11.20221125.8690906`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.0`
 - channels(root): `"nixos-22.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Note that channel info is not meaningful, here's flake.lock:

{
  "nodes": {
    "home-manager": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ],
        "utils": "utils"
      },
      "locked": {
        "lastModified": 1669071065,
        "narHash": "sha256-KBpgj3JkvlPsJ3duOZqFJe6tgr+wc75t8sFmgRbBSbw=",
        "owner": "nix-community",
        "repo": "home-manager",
        "rev": "f7641a3ff398ccce952e19a199d775934e518c1d",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "ref": "release-22.11",
        "repo": "home-manager",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1669379897,
        "narHash": "sha256-XM3xBfQD5tOtV4KAhQHyh53cJdqkLwotZa5JJIUjbQc=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "8690906c4d80db5d85f52313a8487bf2e7b8d4c5",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-22.11",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "home-manager": "home-manager",
        "nixpkgs": "nixpkgs"
      }
    },
    "utils": {
      "locked": {
        "lastModified": 1667395993,
        "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}
@shlevy shlevy added bug triage Issues or feature request that have not been triaged yet labels Nov 26, 2022
@shlevy
Copy link
Author

shlevy commented Nov 26, 2022

@DamienCassou
Copy link
Contributor

Could you please try again without any .emacs.d/ directory or other Emacs configuration file?

@shlevy
Copy link
Author

shlevy commented Nov 27, 2022

Will report back when I've checked.

@futile
Copy link

futile commented Dec 30, 2022

Ran into this issue as well, so can confirm it's happening. What solved the issue for me was putting this into my home-manager config:

  systemd.user.services.emacs = lib.mkIf config.services.emacs.enable {
    Unit = {
      After = [ "graphical-session-pre.target" ];
      PartOf = [ "graphical-session.target" ];
    };

    Install.WantedBy = lib.mkForce [ "graphical-session.target" ];
  };

Home-manager currently sets Install.WantedBy to default.target, which might/will be before the graphical session has started. Thus, only a non-graphical emacs server will be able to start up. The solution of restarting the user emacs service works because during the restart the graphical session is already there.

My workaround/solution configures the home-manager service to use "graphical-session.target" instead of "default.target", so the emacs server is only started once the graphical session has begun.

However, I think I notice a delay when logging in now, which might be due to my desktop waiting until emacs has fully started? Although I'm not really sure about this. Also, "default.target" can still be correct, for example on machines that don't have a graphical session running. My systemd/service knowledge is also not that great, so there might be better solutions here.

@jian-lin
Copy link
Member

FYI, I created a PR three months before this issue was opened.

@DamienCassou
Copy link
Contributor

@shlevy @futile have you tried PR #3010? Does it help you?

@shlevy
Copy link
Author

shlevy commented Feb 23, 2023

I haven't.

@stale
Copy link

stale bot commented May 25, 2023

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

@stale stale bot added the status: stale label May 25, 2023
@shlevy
Copy link
Author

shlevy commented May 25, 2023

Funnily enough I'd started a rebuild with the latest home-manager before seeing the stale notification. Should know soon enough if it works.

@stale stale bot removed the status: stale label May 25, 2023
@shlevy
Copy link
Author

shlevy commented May 25, 2023

Alas, this doesn't suffice, I'm still having to restart on login.

@jian-lin
Copy link
Member

jian-lin commented May 25, 2023

Do you set services.emacs.startWithUserSession = "graphical"?

@shlevy
Copy link
Author

shlevy commented May 25, 2023

🤦 whoops.

Working now (using socket-activation, which is a better way to do it anyway)

@shlevy shlevy closed this as completed May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Issues or feature request that have not been triaged yet
Projects
None yet
Development

No branches or pull requests

7 participants