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

local hooks stopped working after updating to latest verison. #18739

Closed
eyalpazu opened this issue Jun 2, 2024 · 37 comments
Closed

local hooks stopped working after updating to latest verison. #18739

eyalpazu opened this issue Jun 2, 2024 · 37 comments
Labels
bug Confirmed bugs or reports that are very likely to be bugs priority-1 Bug that affects many users in a significant way and prevents core functions

Comments

@eyalpazu
Copy link

eyalpazu commented Jun 2, 2024

The problem

local hooks stopped working after updating to the latest version (Version 3.4.0 (x64)).
The command line works without problems, but it fails to find Python when using the GitHubDesktop GUI.
Error message: "/usr/bin/env: ‘python’: No such file or directory"

Release version

Version 3.4.0 (x64)

Operating system

Windows 10

Steps to reproduce the behavior

Create local hook that uses python.
path: .git/hooks/prepare-commit-msg
And try commit using GitHubDesktop.

Log files

No response

Screenshots

GitHubDesktopProblem

Additional context

No response

@andylwelch
Copy link

andylwelch commented Jun 3, 2024

My pre-commit hooks also failed after updating to 3.4.0 in Windows. I get command not found for the tools that used to work, e.g. npm, yarn. I have been attempting fixes related to path C:\Program Files\Git\bin and the import order without any luck. Following this thread now for any more ideas.

@ivoyip1101
Copy link

My pre-commit hooks also failed after updating to 3.4.0 in Windows. I get command not found for the tools that used to work, e.g. npm, yarn. I have been attempting fixes related to path C:\Program Files\Git\bin and the import order without any luck. Following this thread now for any more ideas.

I have same problem after updating to 3.4.0 in Windows!

@jroach-cordel
Copy link

I'm running into this issue when trying to run pwsh.exe as well.

@CalebSmith0801
Copy link

Same issue here. I have to use the exact file path in my hooks for it to work now.

@ciso-davidpham
Copy link

ciso-davidpham commented Jun 3, 2024

Same issue, wsl2 pre-commit hooks working just fine until this latest update, I've checked the environment variables and everything is setup correctly, pointing to where the git binary is in AppData, getting
'/usr/bin/env: ‘bash’: No such file or directory'

@splitice
Copy link

splitice commented Jun 4, 2024

Best part is github in all their wisdom doesnt publish older builds. So if you get auto-updated to a broken version you better find a new client.

@andylwelch
Copy link

andylwelch commented Jun 4, 2024

I found this download url worked for v3.3.18. Also, rename the Update.exe and it will break the auto-update process...

@glundgren93
Copy link

I think this could've been the root cause.
#18676

@tidy-dev
Copy link
Contributor

tidy-dev commented Jun 4, 2024

👋 The embedded version of Git was recently updated for security reasons. Does anyone have the latest version (2.45.2) Git installed and can successfully run the hooks from the command line?

@TheMikeyRoss
Copy link

I have the latest git 2.45.2 on windows and I have the latest github desktop version 3.4.0 and I'm still having the same issues where any command I use in a git hook will result in a command not found error

@fbastien
Copy link

fbastien commented Jun 4, 2024

@TheMikeyRoss With your setup, does this error only occur within GitHub Desktop, or does it also occur when executing git commit command lines?

@TheMikeyRoss
Copy link

@fbastien It only occurs within the github desktop app. When I make a commit via the terminal the husky hooks run successfully and I face no issues.

I even installed Atlassian Sourcetree to test it out and I faced no issues. So I'm 100% confident the issue is strictly happeniing when I try to make a commit with the Github Desktop app.

@fbastien
Copy link

fbastien commented Jun 4, 2024

Thanks for the clarification

@master-lou
Copy link

Hello,
maybe this will help someone, I ran into the issue of command not found after I updated to 3.4.0, I spent most of yesterday trying to get it to work with no success, at the end, I deleted the local repository, and cloned it from remote, everything is back to normal, I could commit, merge, and everything expected from GithubDesktop is working
so delete your repository ( you can commit your work from CLI ) and clone a new one

@asfo
Copy link

asfo commented Jun 4, 2024

Hello, maybe this will help someone, I ran into the issue of command not found after I updated to 3.4.0, I spent most of yesterday trying to get it to work with no success, at the end, I deleted the local repository, and cloned it from remote, everything is back to normal, I could commit, merge, and everything expected from GithubDesktop is working so delete your repository ( you can commit your work from CLI ) and clone a new one

In the case you use Husky, you just "uninstalled it" so, it's not a real fix, you need to run again npm run prepare (or something like that) and then the error will show up again...

@tidy-dev
Copy link
Contributor

tidy-dev commented Jun 4, 2024

@asfo I tried adding a simple husky pre-commit hook with no luck reproducing this issue. Would you (or anyone) mind sharing your hook setup that I might be able to reproduce it?

@CalebSmith0801
Copy link

CalebSmith0801 commented Jun 4, 2024

@tidy-dev My .husky\pre-commit file looks like so:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx.cmd lint-staged -q

This results in the following error

.husky/pre-commit: line 4: npx.cmd: command not found
husky - pre-commit hook exited with code 127 (error)

[EDIT]
npx.cmd is in C:\Program Files\nodejs\ which I have set in my system PATH variable. This used to work before v3.4.0.

@TheMikeyRoss
Copy link

npx.cmd is in C:\Program Files\nodejs\ which I have set in my system PATH variable. This used to work before v3.4.0.

@CalebSmith0801 It seems PATH variables are ignored in the latest update

@MeridianGH
Copy link

MeridianGH commented Jun 4, 2024

npx.cmd is in C:\Program Files\nodejs\ which I have set in my system PATH variable. This used to work before v3.4.0.

@CalebSmith0801 It seems PATH variables are ignored in the latest update

I can confirm this, it looks like an issue with MinGW replacing/overwriting the path.

I'm getting the following error message when trying to commit with a husky commit-msg hook (see my other comment on this):

.husky/commit-msg: line 4: npx.cmd: command not found
husky - commit-msg script failed (code 127)
husky - command not found in PATH=/mingw64/libexec/git-core:/mingw64/bin:/usr/bin:/c/Users/[my username]/bin:/mingw64/bin:/mingw64/usr/bin:undefined

The undefined at the end of the PATH makes me a bit suspicious... Is the Windows PATH supposed to be appended there?

I tried downgrading to Version 3.3.14 (x64) and the hook worked again. But that is definitely no permanent solution.

EDIT: Yes, it looks like the Windows PATH is definitely missing. I tried echoing the PATH from within the hook while running Version 3.3.14 (x64) and it had the entirety of the Windows PATH appended:

/mingw64/libexec/git-core:/mingw64/bin:/usr/bin:/c/Users/[my username]/bin:/mingw64/bin:/mingw64/usr/bin:/c/Program Files/Mozilla Firefox:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files/WireGuard:/c/Program Files/Docker/Docker/resources/bin:/c/Program Files/dotnet:/c/Program Files/nodejs:/c/Program Files/Git/cmd:/c/Program Files/Git/bin:/c/Users/[my username]/AppData/Local/Microsoft/WindowsApps:/c/Users/[my username]/AppData/Local/GitHubDesktop/bin:/c/Program Files/Git/cmd:/c/Program Files/Git/bin:/c/Users/[my username]/AppData/Local/JetBrains/Toolbox/scripts:/c/Users/[my username]/AppData/Roaming/npm:/c/Users/[my username]/AppData/Local/Microsoft/WindowsApps

@TheBlubb14
Copy link

npx.cmd is in C:\Program Files\nodejs\ which I have set in my system PATH variable. This used to work before v3.4.0.

@CalebSmith0801 It seems PATH variables are ignored in the latest update

I can confirm this, it looks like an issue with MinGW replacing/overwriting the path.

I'm getting the following error message when trying to commit with a husky commit-msg hook (see my other comment on this):

.husky/commit-msg: line 4: npx.cmd: command not found
husky - commit-msg script failed (code 127)
husky - command not found in PATH=/mingw64/libexec/git-core:/mingw64/bin:/usr/bin:/c/Users/[my username]/bin:/mingw64/bin:/mingw64/usr/bin:undefined

The undefined at the end of the PATH makes me a bit suspicious... Is the Windows PATH supposed to be appended there?

I tried downgrading to Version 3.3.14 (x64) and the hook worked again. But that is definitely no permanent solution.

EDIT: Yes, it looks like the Windows PATH is definitely missing. I tried echoing the PATH from within the hook while running Version 3.3.14 (x64) and it had the entirety of the Windows PATH appended:

/mingw64/libexec/git-core:/mingw64/bin:/usr/bin:/c/Users/[my username]/bin:/mingw64/bin:/mingw64/usr/bin:/c/Program Files/Mozilla Firefox:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files/WireGuard:/c/Program Files/Docker/Docker/resources/bin:/c/Program Files/dotnet:/c/Program Files/nodejs:/c/Program Files/Git/cmd:/c/Program Files/Git/bin:/c/Users/[my username]/AppData/Local/Microsoft/WindowsApps:/c/Users/[my username]/AppData/Local/GitHubDesktop/bin:/c/Program Files/Git/cmd:/c/Program Files/Git/bin:/c/Users/[my username]/AppData/Local/JetBrains/Toolbox/scripts:/c/Users/[my username]/AppData/Roaming/npm:/c/Users/[my username]/AppData/Local/Microsoft/WindowsApps

seems the same as #18701 (comment)

@sergiou87
Copy link
Member

sergiou87 commented Jun 4, 2024

Thank you all for digging into this. If it's related to the PATH, it might be caused by these changes: desktop/dugite#563

We'll keep digging 🕵

@MeridianGH
Copy link

@TheBlubb14 Yup, that seems to be it!

@sergiou87
Copy link
Member

Ok I think we've got it… that PR I linked in my previous comment changes the way we grab and modify the PATH environment variable… or more accurately the Path env variable.

process.env allows case-insensitive access to variables on Windows, but when we do ...process.env we break that, and after that point we cannot use env.PATH to access the existing path on Windows, we should use env.Path.

Thank you all again for your help diagnosing the issue 🙇‍♂ We'll try to get a fix out ASAP

@TheMikeyRoss
Copy link

@sergiou87 You get 'em Loofy 🤩

@paulvales
Copy link

same problem with /usr/bin/env: ‘php’: No such file or directory when committing

@tidy-dev
Copy link
Contributor

tidy-dev commented Jun 5, 2024

👋 We believe we have fix. Would any one mind verifying with this 3.4.1-test1 build?

@steveward steveward added bug Confirmed bugs or reports that are very likely to be bugs priority-1 Bug that affects many users in a significant way and prevents core functions labels Jun 5, 2024
@JMazurie
Copy link

JMazurie commented Jun 5, 2024

👋 We believe we have fix. Would any one mind verifying with this 3.4.1-test1 build?

This build fixed the issue for me (described in #18768), thanks a bunch !

@MeridianGH
Copy link

👋 We believe we have fix. Would any one mind verifying with this 3.4.1-test1 build?

+1, this build seems to fix the issue. Echoing the PATH also now shows the correct path with the Windows PATH appended again. Thanks for the fix! 👍

@mkahvi
Copy link

mkahvi commented Jun 5, 2024

👋 We believe we have fix. Would any one mind verifying with this 3.4.1-test1 build?

Confirmed to be working for me as well (for #18705).

@JLeverDynaGen
Copy link

👋 We believe we have fix. Would any one mind verifying with this 3.4.1-test1 build?

Coming from #18701, this build fixes signed commits

@TheMikeyRoss
Copy link

YES

@tidy-dev
Copy link
Contributor

tidy-dev commented Jun 5, 2024

Released! You can now upgrade to 3.4.1 (download here) 🎉

Thanks again everyone! 💖

@tidy-dev tidy-dev closed this as completed Jun 5, 2024
@anupamrwx
Copy link

Thanks alot for fixing this issue. Much awaited fix. 🎉🎉🎉

@east-shine
Copy link

@tidy-dev I'm still having issues with version 3.4.1(arm64)

@tidy-dev
Copy link
Contributor

tidy-dev commented Jun 20, 2024

@east-shine I am sorry to hear that. It is likely a different root cause. Could you open a new issue to track it? (Please remember to include logs)

@exde37b2
Copy link

exde37b2 commented Jun 28, 2024

maybe this helps others.
Having in use 3.4.1, I had run
nvm install fancy.new.version
nvm use fancy.new.version

and ended up with the same problem described above. After running
nvm use good.old.version

GitHubDesktop is working again

@MeridianGH
Copy link

maybe this helps others.
Having in use 3.4.1, I had run
nvm install fancy.new.version
nvm use fancy.new.version

and ended up with the same problem described above. After running
nvm use good.old.version

GitHubDesktop is working again

Have you checked the official Husky instructions for use with NVM?
https://typicode.github.io/husky/how-to.html#node-version-managers-and-guis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bugs or reports that are very likely to be bugs priority-1 Bug that affects many users in a significant way and prevents core functions
Projects
None yet
Development

No branches or pull requests