gitui icon indicating copy to clipboard operation
gitui copied to clipboard

PATH not respected in hooks

Open Lykos153 opened this issue 2 years ago • 5 comments

Describe the bug I use devenv and direnv to make some applications available on a per-directory basis by setting the PATH environment variable. I use it especially to provide project specific git hooks. However, when committing with gitui, those applications don't seem to be available.

To Reproduce Steps to reproduce the behavior:

  1. Create a script somewhere, lets call it my-own-script
  2. Add its parent to the PATH
  3. Create a pre-commit hook that uses my-own-script
  4. Try to commit using gitui
  5. See it fail because it can't find my-own-script

Expected behavior gitui being able to see applications in the PATH

Context (please complete the following information):

  • NixOS unstable
  • gitui 0.24.3

Lykos153 avatar Dec 01 '23 11:12 Lykos153

that is so weird. we use https://doc.rust-lang.org/std/process/struct.Command.html#method.new and it is supposed to inherit the parents env

extrawurst avatar Dec 01 '23 12:12 extrawurst

#1968 adds a unittest proving that a hook script has access to PATH on all ci platforms

extrawurst avatar Dec 02 '23 12:12 extrawurst

@Lykos153 can you export your environment in your hook for debug purposes like you see it happening in the referenced unittest. I cannot reproduce your problem

extrawurst avatar Dec 03 '23 23:12 extrawurst

Thank you very much for looking into it! And you're right. I realized that with zsh it is indeed working as expected. It only seems to happen using nushell. But what's strange is that it works with git but not with gitui. Whats the difference in how both call the hook? See https://asciinema.org/a/jXDeNAlsYFHs6TSlALE6KGDnr

I will ask the nushell folks, too.

Lykos153 avatar Dec 05 '23 13:12 Lykos153

very strange indeed. i am not using nushell. it seems for some reason the gitui process does not see the new version of the env

extrawurst avatar Dec 05 '23 13:12 extrawurst

closing in case we find new evidence

extrawurst avatar Feb 11 '24 18:02 extrawurst