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

Husky - pre-commit hook exited with code 127 (error) #1478

Open
gwendal-sogeti opened this issue Jul 25, 2024 · 7 comments
Open

Husky - pre-commit hook exited with code 127 (error) #1478

gwendal-sogeti opened this issue Jul 25, 2024 · 7 comments

Comments

@gwendal-sogeti
Copy link

Describe the bug

WHen I try to commit either from the terminal, intellij IDE, Intellij IDE terminal or even Github Desktop, I get an error and the commit fail.

Version & OS

I am using Windows 11 and my husky version is 8.0.3

Steps to reproduce the behavior

Run git commit from the terminal or Intellij IDEA

Expected behavior

The commit is pushed.

Actual behavior

The commit isn't pushed and it gives an error.

Screenshots

image

Logs

11:17:18.544: [GoldenEye_back_java] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false reset -- package-lock.json
11:17:18.861: [GoldenEye_back_java] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false add --ignore-errors -A -f -- src/main/java/com/sogeti/goldeneye/controller/ProjectController.java src/main/java/com/sogeti/goldeneye/repository/ProjectRepository.java src/main/java/com/sogeti/goldeneye/service/ProjectService.java src/main/java/com/sogeti/goldeneye/service/impl/ProjectServiceImpl.java
11:17:19.155: [GoldenEye_back_java] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false commit -F C:\Users\gwbreton\AppData\Local\Temp\git-commit-msg-.txt --
.husky/pre-commit: line 4: make: command not found
husky - pre-commit hook exited with code 127 (error)
husky - command not found in PATH=/mingw64/libexec/git-core:/mingw64/bin:/usr/bin:/c/Users/gwbreton/bin:/c/Program Files/Eclipse Adoptium/jdk-21.0.3.9-hotspot/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/cmd:/c/Program Files/dotnet:/c/Program Files/nodejs:/c/Users/gwbreton/OneDrive - Capgemini/Documents/apache-maven-3.9.8-bin/apache-maven-3.9.8:/c/Users/gwbreton/scoop/shims:/c/Users/gwbreton/AppData/Local/Microsoft/WindowsApps:/c/Users/gwbreton/AppData/Local/Programs/Microsoft VS Code/bin:/c/Users/gwbreton/.dotnet/tools:/c/Users/gwbreton/AppData/Local/GitHubDesktop/bin:/c/Program Files/JetBrains/IntelliJ IDEA 2024.1.4/bin
11:17:20.719: [GoldenEye_back_java] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false add --ignore-errors -A -f -- package-lock.json
@typicode
Copy link
Owner

Not really an issue with husky. It's due to make not being found in PATH.

If you run the content of pre-push manually in your terminal and it works, try displaying PATH and compare it with the one from husky - command not found in PATH=. It may help you find which directory is missing.

You can also start VSCode from the terminal so that it inherits the PATH with the directory containing make.

@uniabis
Copy link

uniabis commented Jul 26, 2024

Husky 9.1.2 cannot handle PATH with spaces.

husky/husky

Line 16 in 35fba84

export PATH=node_modules/.bin:$PATH

export PATH="node_modules/.bin:$PATH"

@gwendal-sogeti
Copy link
Author

gwendal-sogeti commented Jul 26, 2024

I tried running pre-push in Intellij IDEA and it gave me an error related to /bin/sh :

 C:\Users\gwbreton\OneDrive - Capgemini\Documents\GoldenEye_back_java\.husky> /bin/sh "C:/Users/gwbreton/OneDrive - Capgemini/Documents/GoldenEye_back_java/.husky/pre-push"
/bin/sh : Le terme «/bin/sh» n'est pas reconnu comme nom d'applet de commande, fonction, fichier de script ou programme exécutable. Vérifiez        
l'orthographe du nom, ou si un chemin d'accès existe, vérifiez que le chemin d'accès est correct et réessayez.
Au caractère Ligne:1 : 1
+ /bin/sh "C:/Users/gwbreton/OneDrive - Capgemini/Documents/GoldenEye_b ...
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (/bin/sh:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

It's written in French but it says that "/bin/sh" is not recognized as a command, function, script file or executable.

Also. Here is the result of my path variable

PS C:\Users\gwbreton\OneDrive - Capgemini\Documents\GoldenEye_back_java\.husky> echo $Env:PATH
C:\Program Files\Eclipse Adoptium\jdk-21.0.3.9-hotspot\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerS
hell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Users\gwbreton\OneDrive - Capg
emini\Documents\apache-maven-3.9.8-bin\apache-maven-3.9.8;C:\Program Files\Git\usr\bin\cygpath.exe;C:\Users\gwbreton\scoop\shims;C:\Users\gwbreton\A
ppData\Local\Microsoft\WindowsApps;C:\Users\gwbreton\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\gwbreton\.dotnet\tools;C:\Users\gwbreton\
AppData\Local\GitHubDesktop\bin;C:\Program Files\JetBrains\IntelliJ IDEA 2024.1.4\bin;;C:\Program Files\Git\usr\bin\cygpath.exe;;C:\Users\gwbreton\OneDrive - Capgemini\Documents\GoldenEye_back_java\node_modules\.bin

@Fdawgs
Copy link

Fdawgs commented Jul 26, 2024

Also hitting the exact same issue with 9.1.2 when using WSL.

OS: Windows 11 using Ubuntu 22.04.4 via WSL
Node: 20.16.0
Husky: 9.1.2

@typicode
Copy link
Owner

v9.1.3+ should better handle space in path if that's the issue

@Fdawgs
Copy link

Fdawgs commented Jul 29, 2024

Brilliant, thanks @typicode!

@typicode
Copy link
Owner

thanks to @uniabis for pointing it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants