Skip to content

Pre-commit hooks such as lefthook cause an error saying env: node: No such file or directory #236

Open
@0-CAT

Description

@0-CAT

Describe the bug

When using a pre-commit hook such as lefthook, it is impossible to commit due to a popup error indicating that node was not found.

To Reproduce

  1. Create a new folder and open the terminal.
  2. Run Terminal commands:
echo "node_modules\n.DS_Store" > .gitignore
git init
git add -A
git commit -m "Initialize repo"
npm install --save-dev lefthook
  1. Replace the contents of lefthook.yml with the following content:
pre-commit:
  commands:
    check:
      glob: "*.{txt}"
      run: node -v
  1. Run Terminal commands:
git add -A && git commit -m "Add lefthook"
echo Test > README.md
  1. Open the above created repository in Gitnuro.
  2. Stage README.md and add a commit message.
  3. Click "Commit".

An error saying that node cannot be found will be shown, even if Node is installed and available on the terminal path. (It even works if I pop open a terminal from Gitnuro and run node -v or git commit.)

Expected behavior

The commit hook should run exactly as it does if using git commit from the CLI, and no error should be shown.

Screenshots

CleanShot 2024-09-08 at 16 48 24

CleanShot 2024-09-08 at 17 01 30

Desktop (please complete the following information):

OS: macOS 15.1
Gitnuro version: 1.3.1

CleanShot 2024-09-08 at 17 15 21

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions