Problem

When trying to commit in GitHub Desktop (Windows environment) to a repository that runs a Husky pre-commit hook, I got the following error message:

/usr/bin/env: ‘bash’: No such file or directory husky - pre-commit hook exited with code 127

Solution

I found this solution in a discussion on GitHub and it worked for me.

Here’s what I did to solve it:

  1. Open Environment Variables by typing “Edit the system environment variables” in the Windows search bar.

  2. Click the “Environment Variables…” button.

  3. Under the “System variables” section, edit “Path”.

  4. “New” -> set C:\Program Files\Git\bin as the value.

  5. Click the “Move Up” button so it is placed before the %SystemRoot%\system32 line.

  6. Save and apply.

  7. Restart GitHub Desktop and try again.

References