How to solve `No such file or directory` error in systemd service?

I am running dwm and using clipmenu.
My NixOS is using flake.
I have this line in configuration.nix:

	services.clipmenu.enable = true;

The clipmenud works as expected before but the daemon cannot be launched recently.
When I check with command systemd --user status clipmenu.service, it shows these error messages:

× clipmenu.service - Clipboard management daemon
     Loaded: loaded (/home/user/.config/systemd/user/clipmenu.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-05-14 18:43:37 CST; 7s ago
   Duration: 2ms
    Process: 404236 ExecStart=/nix/store/jxn1d8a6akz5rv58q6k83r8avs3qjk93-clipmenu-6.2.0/bin/clipmenud (code=exited, status=203/EXEC)
   Main PID: 404236 (code=exited, status=203/EXEC)
        CPU: 1ms

May 14 18:43:37 nixos systemd[3541]: Started Clipboard management daemon.
May 14 18:43:37 nixos (lipmenud)[404236]: clipmenu.service: Failed to locate executable /nix/store/jxn1d8a6akz5rv58q6k83r8avs3qjk93-clipmenu-6.2.0/bin/clipmenud: No such file or directory
May 14 18:43:37 nixos (lipmenud)[404236]: clipmenu.service: Failed at step EXEC spawning /nix/store/jxn1d8a6akz5rv58q6k83r8avs3qjk93-clipmenu-6.2.0/bin/clipmenud: No such file or directory
May 14 18:43:37 nixos systemd[3541]: clipmenu.service: Main process exited, code=exited, status=203/EXEC
May 14 18:43:37 nixos systemd[3541]: clipmenu.service: Failed with result 'exit-code'.

The output of cd /nix/store/jxn1d8a6akz5rv58q6k83r8avs3qjk93-clipmenu-6.2.0:

cd: no such file or directory: /nix/store/jxn1d8a6akz5rv58q6k83r8avs3qjk93-clipmenu-6.2.0

The output of nix-store -q $(which clipmenud) points to another valid path:

/nix/store/0m5ip7ygyrymv8z0qaka7qhjar0zlprd-clipmenu-6.2.0

I tried disabling and enabling the services.clipmenu.enable = true; but nothnig changed.

I recently use these options in configuration.nix

nix.optimise.automatic = true;
programs.nh.clean = {
        enable = true;
        extraArgs = "--keep-since 30d";
};

Maybe they messed up the path in nix store?
What should I do? Thanks for your help!

please, correct me if i’m wrong, but this path looks like something you’ve created manually, as nixos creates user services in /etc/systemd/user dir.

so if that service definition is not linking to nix store - then that’s something you’ve created manually, with hardcoded nix paths, and the paths were garbage collected

1 Like

If you search the NixOS options for services.clipmenu NixOS Search

and then click into the source, it shows it’s setting systemd.user.services.clipmenu.

(That said, I would find it unusual if rebuilding a system configuration resulted in a path that didn’t exist).

yes, i did check that, and because of that i said that user services are created at /etc/systemd/user dir, not in ~/.config/systemd/....

at least all my user systemd services are in /etc/systemd/user, and i don’t have ~/.config/systemd at all

1 Like

I have one service under ~/.config/systemd/user, from enabling gnome-keyring in home-manager, and it works. Everything else is in /etc/systemd/user.

Yes, Thank you so much for pointing it out!
I see 3 files (not symlink created by home-manager) in /home/user/.config/systemd/user folder

clipmenu.service
gpg-agent.service
gpg-agent-ssh.socket

Deleting those files and gpg-agent and clipmenu start working again.

2 Likes