jD91mZM2/xidlehook

warning: failed to invoke command: No such file or directory (os error 2)

Closed this issue · 5 comments

I'm having some problems with xidlehook on NixOS. I tried to write a systemd service but it just doesn't work. It gives errors like:

warning: failed to invoke command: No such file or directory (os error 2)

Here is my nix configuration (with some strace for debugging), and here's the strace log: https://gist.github.com/jluttine/df72194b671b1ba388903fbdc477e346

I guess this is a simple way to see the failure:

PATH="" /run/current-system/sw/bin/xidlehook --timer normal 5 "/run/current-system/sw/bin/echo hello" "/run/current-system/sw/bin/echo goodbye"
warning: failed to invoke command: No such file or directory (os error 2)
warning: failed to invoke command: No such file or directory (os error 2)

Any ideas what's going on?

In strace log it's weird that it's referencing a huge number of non-existent nix store paths..

I'd guess it's due to a lack of sh in the path, as it currently relies on sh -c. I should definitely have a flag to override the path to that executable.

EDIT: The reason for the spam in strace is because of how libc works when you search for an executable in $PATH: It tries each one.

Perhaps use /bin/sh instead of sh? I guess that should be standard and works in NixOS too, then you don't need to be able to override the path.

EDIT: I don't know whether that would fix the issue, but if the problem is that sh isn't found, then I guess using /bin/sh should solve that.

I can confirm that this patching on NixOS fixes the issue:

    nixpkgs.overlays = lib.singleton (
      self: super: {
        xidlehook = super.xidlehook.overrideAttrs (oldAttrs: {
          postPatch = ''
            substituteInPlace src/main.rs --replace '"sh"' '"/bin/sh"'
          '';
        });
      }
    );

Thanks, I'll fix it :)

I forgot to mention, sorry, but latest xidlehook fixes this :)