jD91mZM2 / xidlehook

GitLab: https://gitlab.com/jD91mZM2/xidlehook
MIT License
387 stars 33 forks source link

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

Closed jluttine closed 4 years ago

jluttine commented 5 years ago

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..

jD91mZM2 commented 5 years ago

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.

jluttine commented 5 years ago

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.

jluttine commented 5 years ago

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"'
          '';
        });
      }
    );
jD91mZM2 commented 5 years ago

Thanks, I'll fix it :)

jD91mZM2 commented 4 years ago

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