Skip to content

Git pre-commit hook fails to run because of "No such file or directory" #12586

@saschanaz

Description

@saschanaz

Describe the bug

I have a .git/hooks/pre-commit which is exactly the following:

#!/bin/sh
npm test

When I commit via GitHub Desktop, it fails:

/bin/bash: C:/Program Files/nodejs/npm: No such file or directory

It works when committing via git CLI.

Version & OS

Open 'About GitHub Desktop' menu to see the Desktop version. Also include what operating system you are using.

Steps to reproduce the behavior

  1. Create a hook as .git/hooks/pre-commit
  2. Commit something
  3. See error

Expected behavior

It should run the npm command

Actual behavior

It says no such file

Screenshots

image

Logs

2021-07-09T14:34:12.623Z - info: [ui] [Timing] Action 'create commit' for 'saschanaz/types-web' took 0.292s
2021-07-09T14:35:53.954Z - info: [ui] Executing createCommit: git commit -F - (took 1.372s)
2021-07-09T14:35:53.963Z - error: [ui] `git commit -F -` exited with an unexpected code: 1.
stderr:
/bin/bash: C:/Program Files/nodejs/npm: No such file or directory

Additional context

This had been working but is regressed since a few months ago.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions