nix run has confusing behavior and bad error messages #435

Open
opened 2024-07-07 19:09:10 +00:00 by lunaphied · 0 comments
Owner

If I feed a derivation generated from Nixpkgs writeShellScript to nix run, it fails with the error error: unable to execute '/nix/store/m06rfjr6f5yzr7q3cf3870sbafj7csph-meow.sh/bin/meow.sh': Not a directory, however, if I switch to writeShellScriptBin it works fine.

This isn't particularly clear behavior and that error needs improvement.

nix run's heuristics for determining the path to the program to execute is also worth improving, as it has a few fixed assumptions including that /bin/${whateverTheProgramWasDeterminedToBeCalled} is always the path. This is arguably also a failure of Nixpkgs since meta.mainProgram should probably have been defined to be an absolute path, unfortunately we're stuck with it now.

Tasks

  • Improve error message for failing to find the executable or finding a non-executable file
  • Decide on and implement new heuristics for determining the path to the executable that supports derivations that aren't directories.
  • As part of the above, potentially canonicalize the path determined, since arguably more code in Lix should do this
  • (Unlikely) consider getting meta.mainProgram redefined to be a fully qualified path to the program rather than simply the name of the executable with the assumption it's in ${outPath}/bin/${mainProgram}
If I feed a derivation generated from Nixpkgs `writeShellScript` to `nix run`, it fails with the error `error: unable to execute '/nix/store/m06rfjr6f5yzr7q3cf3870sbafj7csph-meow.sh/bin/meow.sh': Not a directory`, however, if I switch to `writeShellScriptBin` it works fine. This isn't particularly clear behavior and that error needs improvement. `nix run`'s heuristics for determining the path to the program to execute is also worth improving, as it has a few fixed assumptions including that `/bin/${whateverTheProgramWasDeterminedToBeCalled}` is always the path. This is arguably also a failure of Nixpkgs since `meta.mainProgram` should probably have been defined to be an absolute path, unfortunately we're stuck with it now. ### Tasks - [ ] Improve error message for failing to find the executable or finding a non-executable file - [ ] Decide on and implement new heuristics for determining the path to the executable that supports derivations that aren't directories. - [ ] As part of the above, potentially canonicalize the path determined, since arguably more code in Lix should do this - [ ] (Unlikely) consider getting `meta.mainProgram` redefined to be a fully qualified path to the program rather than simply the name of the executable with the assumption it's in `${outPath}/bin/${mainProgram}`
lunaphied added the
ux
docs
E/easy
labels 2024-07-07 19:09:10 +00:00
lunaphied self-assigned this 2024-07-07 19:09:10 +00:00
qyriad was assigned by lunaphied 2024-07-07 19:09:10 +00:00
lunaphied changed title from `nix run` error messages aren't clear to `nix run` has confusing behavior and bad error messages 2024-07-07 19:09:41 +00:00
lunaphied removed the
E/easy
label 2024-07-07 19:09:52 +00:00
lunaphied removed the
ux
label 2024-07-07 19:34:21 +00:00
Sign in to join this conversation.
No milestone
No project
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#435
No description provided.