-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Desktop fails to run pre-commit hooks on node 16+ #12562
Comments
@ImRodry thanks for reporting this. GitHub Desktop ships with an internal version of Git which we use for all actions inside the app. As such the environment within which your commit hooks execute will likely not exactly match that of your normal environment. You can take a look at #9351 and see if the workaround in #9351 (comment) is applicable to your situation. One user also had success by changing the husky command from This comment and this comment also have some potential workarounds for this issue. Let me know if any of that helps. |
@steveward thanks for the response. I tried all of the suggestions you linked (some didn't apply to my scenario though) and none worked nor did they produce a different kind of error. The error is still the same as the one I attached in the initial message :/ |
I get a similar error described in #13307 But for me, it's bash that fails:
Additional Info: I have now installed node V14.17.1, and it is working without errors. This issue seems to be connected to the applied version. |
@JosefBredereck same here, after updating node v14 to the latest v16 I see this error from Husky + Lint Staged: |
Similar problem here also. Win10 + Husky v7 + Github Desktop Not running through WSL but I have Git Bash installed. |
I upgraded to Node v16 and husky stopped working with the same error as above. I then downgraded to v14 of Node and it worked again. v16.13.1 x64 didn't work (latest LTS) |
I had a parade of issues with Husky 7 and Node 16 on GitHub Desktop, which I resolved by:
At last it is working. The fault seems to lie somewhere between Node 16, and Desktop insisting on using its built in version of Git. 🤷 |
Ugly but work: npm -> npm.cmd
npx -> npx.cmd |
helped. Thanks |
Have just run into the same underlying WSL on windows issue trying to use pre-commit (https://github.com/pre-commit/pre-commit), which generates this pre-commit hook after running #!/usr/bin/env bash
# File generated by pre-commit: https://pre-commit.com
# ID: 138fd403232d2ddd5efb44317e38bf03
# start templated
INSTALL_PYTHON='c:\program files\python39\python.exe'
ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-commit)
# end templated
if [ -x "$INSTALL_PYTHON" ]; then
... |
I also get:
To:
This is more like a heavy workaround and it gets reverted automatically after updateing I guess. @steveward |
This reverts commit d0f3b6d. - Experiencing issues with commits in GitHub desktop. - Issues appear to have no non-hacky fix. - So reverting changes. - see typicode/husky#1072 - see desktop/desktop#12562 - see desktop/desktop#9351
Any update on this? |
It worked, thanks. |
能不能尽快解决 |
/usr/bin/env: ‘bash’: No such file or directory |
I have the same issue: I also get the error
It seems that the pre-commit hook (which is executed within WSL) tries to access nodejs on my regular computer. The solution proposed by @CameronJThomas does not work for me, the path to GIT is already set in my Any other solutions? |
@wilddeer try installing node14.x on your windows computer in order to get rid of this error. node14.x will show the real error (if any) |
This is the only solution that worked for me. Thanks a lot. |
This has been driving me nuts, I was editing the pre-commit hook to change npx -> npx.cmd and just not staging it but that was getting very annoying. This was the only thing that worked. Thank you! |
Adding |
The second works for me. System Enviroment Variables -> Path -> New -> Add Close Github Desktop, an open again and all works. |
Please on which file am I supposed to edit these? |
It works, Thanks |
@ebesscore |
this worked for me, but will it break on unix machines when they fork? #!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx.cmd lint-staged |
It should break on UNIX machines with a message like "npx.cmd: command not found". I addressed this issue in my reply here (so it works on both UNIX and Windows machines): |
MARK |
@Puyodead1 |
This worked for me: |
slight optimizations, but the original answer helped
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
case $(uname) in
*CYGWIN* | *MINGW* | *MSYS*)
npx.cmd lint-staged # bug on Windows/Github Desktop: add `.cmd` extension fixes it
;;
*)
npx lint-staged
;;
esac |
GitHub Desktop Windows OS error: desktop/desktop#12562, and none of these solutions works.
just check if nvm is installed or not |
Describe the bug
On Windows systems with WSL installed, GitHub desktop will run pre-commit scripts on WSL instead of running them in PowerShell regardless of which shell the user has picked to use. This results in the scripts looking for windows locations that don't exist on WSL.
Version & OS
Version 2.9.0 on Windows 10 21H1 build 19043.1081 running with WSL 2 on Ubuntu 20.04
Steps to reproduce the behavior
Expected behavior
GitHub desktop runs the pre-commit scripts on windows PowerShell, just like git does (tested this)
Actual behavior
The scripts are run on WSL which causes errors
Screenshots
(this path is correct for my system but may be different on others)
Logs
This log has the error multiple times, which should help.
2021-07-03.desktop.production.log
Additional context
Got this error on the repositories discordjs/discord.js and discordjs/builders (forks of them) so you can try committing on these to see if you get the same errors. I also believe this issue should have relatively high priority since I am incapable of committing through my PC (unless I use git, which is more limited on some things and harder for me)
The text was updated successfully, but these errors were encountered: