Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
0-CAT opened this issue Sep 9, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@0-CAT
Copy link

0-CAT commented Sep 9, 2024

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

@0-CAT 0-CAT added the bug Something isn't working label Sep 9, 2024
@xoniq
Copy link

xoniq commented Oct 9, 2024

Has this been resolved yet? I try to use a pre-commit hook to set the timestamp in a file, which then is used in my project to reload assets to cache based on that, so cache refreshes with new builds.

But I cannot use git binary in the githook when it goes via Gitnuro. Tried git, /bin/git, /usr/bin/git nothing works.

It does work perfectly fine when I use git commit -m "xx" on my terminal. So its isolated to how Gitnuro handles this.

@JetpackDuba
Copy link
Owner

Hello! I haven't tried it yet, sorry. I'll try to give some feedback during the weekend.

@xoniq
Copy link

xoniq commented Oct 12, 2024

Hello! I haven't tried it yet, sorry. I'll try to give some feedback during the weekend.

I have tested it on macOS, with the same pre-commit hook, there it works. I had some other unrelated issues with my Mint installation, so decided to go new install with it.

ully new Linux Mint 22 installation, same pre-commit hook, clean flatpack Gitnuro install, exactly the same issue on exec git add.

@JetpackDuba
Copy link
Owner

That's probably due to Flatpak sandboxing, it's a different issue. As a workaround, does it work if you add this before the git command? /usr/bin/flatpak-spawn --host --env=TERM=xterm-256color

@xoniq
Copy link

xoniq commented Oct 12, 2024

I'll try that. I normally always install via DEB files, I'll try it soon, will be at home soon. I'll reply to this with the result, so future people might find this.

@xoniq
Copy link

xoniq commented Oct 12, 2024

@JetpackDuba thank you so much, that was it. For reference, this is what I use:

exec /usr/bin/flatpak-spawn --host --env=TERM=xterm-256color git add .....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants