Open svadhis opened 1 year ago
I have this error only when git hook is set
Same error with git hook set
@svadhis @DylanDelobel hi
do you guys have windows?
ok i see, it's windows, i dont have one, so hard to reproduce and debug, maybe one of you want to solve it and make a PR?
@di-sukharev Yes for Windows as env
I have hard time to track down what going bad but yeah I will make a PR if I found a fix
I am also getting the same error on windows.
yep, hook on windows looks like not working properly. @Mutahhar @DylanDelobel you could fork the repo and run code locally with npm run dev -- hook set
and npm run dev -- commit
to see the error log
I tried digging into this, and it seems like the cause is because of how isHookCalled
checks if process.argv[1]
ends with SYMLINK_URL
. As seen here.
To be exact, the problem is SYMLINK_URL
use forward slash, while in windows, file path uses backslash as delimiter, thus isHookCalled
is false
even though it does called from a hook, and cli run commit()
instead of prepareCommitMessageHook()
.
I think there are some way to solve this problem, but the two solutions that I tested is to check process.argv[1]
properly according to the platform where the program is currently running in, simply by checking if process.platform
is win32
.
And the other solution is to change isHookCalled
to check process.stdin.isTTY
instead, because inside pre-commit
or prepare-commit-msg
hook there is no user interactivity (I couldn't find the documentation for it, but it's a common problem when I googled it). And from my test, process.stdin.isTTY
is undefined
when I ran git commit
, and its true
when I ran npm run dev -- commit
, so it is as expected.
In both solutions, git commit
called the hook with no error, and the generated message inserted to COMMIT_EDITMSG
as expected.
will try to add this asap, thanks @hufuhufu <3 <3
Thanks @hufuhufu for the RCA. I like the idea of checking the platform first. I have a windows machine I can test this on will push the change with #48
So the path module is platform independent. By default, the path module automatically switches between POSIX (OSX, Linux) and Windows modes based on which OS your Node process is running. Simply switch to path.join instead of specifying the delimiters should resolve the issue.
On dev dev branch there seems to be another windows incompatible mod used (venv) PS C:\develop\git\openai\opencommit> npm install -g dev npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for inotify@1.4.6: wanted {"os":"linux"} (current: {"os":"win32","arch":"x64"}) npm ERR! notsup Valid OS: linux npm ERR! notsup Valid Arch: undefined npm ERR! notsup Actual OS: win32 npm ERR! notsup Actual Arch: x64
Stale issue message
reopen ..never ahs been solved
I'm running into a similar problem (though Yarn on Linux).
While looking for answers I stumbled on this, which may provide some answers/clues (even though it's for Husky, looks quite similar)
https://github.com/typicode/husky/issues/850#issuecomment-774231951
Config: VS Code on Windows 11
Getting error ERR_TTY_INIT_FAILED when generating commit.
I have same error when using command oc, or using VS Code commit button with git hook set.