-
-
Notifications
You must be signed in to change notification settings - Fork 905
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
OSError: [WinError 193] %1 is not a valid Win32 application when commiting LFS-enabled repository on Windows #971
Comments
It looks like Anyone able to reproduce it is invited to figure out how to execute such a hook on windows, PRs to fix this are very welcome. |
I have encountered the same problem, identical setup. My workaround is now to directly invoke git through subprocess:
|
@Byron The following fix works on Windows for me: In file: \git\index\fun.py, run_commit_hook() change this line: To this: This makes the git bash script run as "bash someBash" instead of "someBash". On most systems the "bash" is redundant but on Windows "bash" will explicitly execute bash, which fixes the problem on my Windows machine. I am not sure this is an appropriate solution, but given my limited knowledge of bash on various platforms, it seems to work. What is slightly mysterious is that the other bash scripts (pre-commit, for example) seem to work fine without this fix. The git large file system must be doing something slightly different in post-commit. If this is acceptable, I would happily submit a fix (or you can submit the fix yourself, and I won't have to clone the repository. :) ) |
Interestingly It's great to have a workaround for this, and adding it to GitPython should be alright if it only triggers on windows and for this kind of hook. Please feel free to submit a PR. I am sure there is a very logical explanation to this as well, and probably it would be better to find that instead of going with what might end up looking like a 'hack'. If it never causes problems, that should be alright, and if it does we would have to revert it and search for a proper fix. |
Fix gitpython-developers#971. If the hook doesn't have a file extension, then Windows won't know how to run it and you'll get "[WinError 193] %1 is not a valid Win32 application". It's very likely that it's a shell script of some kind, so use bash.exe (commonly installed via Windows Subsystem for Linux). We don't want to run all hooks with bash because they could be .bat files. os.name [seems to be the best way to check for Windows][1] and it should certainly ensure we don't do this on other platforms. [1]: https://stackoverflow.com/questions/1325581/how-do-i-check-if-im-running-on-windows-in-python
Fix gitpython-developers#971. If the hook doesn't have a file extension, then Windows won't know how to run it and you'll get "[WinError 193] %1 is not a valid Win32 application". It's very likely that it's a shell script of some kind, so use bash.exe (commonly installed via Windows Subsystem for Linux). We don't want to run all hooks with bash because they could be .bat files. os.name [seems to be the best way to check for Windows][1] and it should certainly ensure we don't do this on other platforms. Update tests to get several hook ones working. More work necessary to get commit-msg hook working. The hook writes to the wrong file because it's not using forward slashes in the path: C:\Users\idbrii\AppData\Local\Temp\bare_test_commit_msg_hook_successy5fo00du\CUsersidbriiAppDataLocalTempbare_test_commit_msg_hook_successy5fo00duCOMMIT_EDITMSG [1]: https://stackoverflow.com/questions/1325581/how-do-i-check-if-im-running-on-windows-in-python
Fix gitpython-developers#971. Partly resolve gitpython-developers#703. If the hook doesn't have a file extension, then Windows won't know how to run it and you'll get "[WinError 193] %1 is not a valid Win32 application". It's very likely that it's a shell script of some kind, so use bash.exe (commonly installed via Windows Subsystem for Linux). We don't want to run all hooks with bash because they could be .bat files. Update tests to get several hook ones working. More work necessary to get commit-msg hook working. The hook writes to the wrong file because it's not using forward slashes in the path: C:\Users\idbrii\AppData\Local\Temp\bare_test_commit_msg_hook_successy5fo00du\CUsersidbriiAppDataLocalTempbare_test_commit_msg_hook_successy5fo00duCOMMIT_EDITMSG
Fix #971. Partly resolve #703. If the hook doesn't have a file extension, then Windows won't know how to run it and you'll get "[WinError 193] %1 is not a valid Win32 application". It's very likely that it's a shell script of some kind, so use bash.exe (commonly installed via Windows Subsystem for Linux). We don't want to run all hooks with bash because they could be .bat files. Update tests to get several hook ones working. More work necessary to get commit-msg hook working. The hook writes to the wrong file because it's not using forward slashes in the path: C:\Users\idbrii\AppData\Local\Temp\bare_test_commit_msg_hook_successy5fo00du\CUsersidbriiAppDataLocalTempbare_test_commit_msg_hook_successy5fo00duCOMMIT_EDITMSG
Hi. I found that GitPython 3.0.5 throw errors when committing to LFS-enabled repository.
Here is error log:
This can be reproduced by following code:
Target repository is LFS-enabled and *.png are tracked.
The text was updated successfully, but these errors were encountered: