devops-kung-fu/hookz

Shell location hardcoded

dantefromhell opened this issue · 2 comments

Issue

NixOS is a Linux distribution that does not implement to the FHS (Filesystem Hierarchy Standard) https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

hookz hardcodes the location of bash as /bin/bash which does not work on all Linux systems, incl. NixOs.

Workaround

Editing the hook files in .git/hooks and replacing /bin/bash by /usr/bin/env bash fixes the issue on NixOS but gets overriden on every execution of hookz reset.

@dantefromhell - if you run the command which bash on NixOS do you get /usr/bin/env, /usr/bin/env/bash or /usr/bin/env bash? (sorry, not familiar with NixOS) If so, I'll find the location of bash before writing the scripts out to the .git/hooks folder and ensure the rendering of the scripts is correct.

NixOS works very differently from other linux distros, there is no fixed path for bash. It depends on the specific version installed. My current bash path is /nix/store/44v410nnqkqngfz430cl1b9wl9ri7bjv-bash-interactive-5.1-p16/bin/bash and it will change with the next update.

Hence the workaround/ fix mentioned in OP to use /usr/bin/env bash in the shebang instead of the hardcoded path. From what I understand the env command is built for exactly this purpose: to resolve distro specific paths to files.