[英]running pre-commit python package in Windows gives ExecutableNotFoundError: Executable `/bin/sh`
我正在处理一个项目,其中pre-commit==2.15.0
2.15.0 被添加到 python 需求文件中。 我安装了要求。 现在,当我尝试执行git commit
时,出现以下错误:
An unexpected error has occurred: ExecutableNotFoundError: Executable `/bin/sh` not found
Check the log at C:\Users\username\.cache\pre-commit\pre-commit.log
在我的预提交日志中,我有:
pre-commit version: 2.15.0
sys.version:
3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
sys.executable: c:\users\username\appdata\local\programs\python\python39\python.exe
os.name: nt
sys.platform: win32
Traceback (most recent call last):
File "c:\users\username\appdata\local\programs\python\python39\lib\site-packages\pre_commit\error_handler.py", line 65, in error_handler
yield
File "c:\users\username\appdata\local\programs\python\python39\lib\site-packages\pre_commit\main.py", line 368, in main
return hook_impl(
File "c:\users\username\appdata\local\programs\python\python39\lib\site-packages\pre_commit\commands\hook_impl.py", line 231, in hook_impl
retv, stdin = _run_legacy(hook_type, hook_dir, args)
File "c:\users\username\appdata\local\programs\python\python39\lib\site-packages\pre_commit\commands\hook_impl.py", line 42, in _run_legacy
cmd = normalize_cmd((legacy_hook, *args))
File "c:\users\username\appdata\local\programs\python\python39\lib\site-packages\pre_commit\parse_shebang.py", line 82, in normalize_cmd
exe = normexe(cmd[0])
File "c:\users\username\appdata\local\programs\python\python39\lib\site-packages\pre_commit\parse_shebang.py", line 61, in normexe
_error('not found')
File "c:\users\username\appdata\local\programs\python\python39\lib\site-packages\pre_commit\parse_shebang.py", line 51, in _error
raise ExecutableNotFoundError(f'Executable `{orig}` {msg}')
pre_commit.parse_shebang.ExecutableNotFoundError: Executable `/bin/sh` not found
我在 Windows 工作,我的队友在 Mac 上工作。
看起来 precommit 正在尝试引用不在 Windows 中的/bin/sh
脚本。如何让这个 precommit 工作?
您以前的.git/hooks/pre-commit.legacy
.git/hooks/pre-commit
使用的是不可移植的 shebang ( #!/bin/sh
) )
如果您将工具调整为使用#!/usr/bin/env sh
那么预提交将能够运行它(即使在 Windows 上)
或者,如果您不想在迁移模式下使用pre-commit
,请运行pre-commit install --force
您还使用了过时的pre-commit
版本,这可能会导致您的问题——因此我建议您进行升级
免责声明:我创建了预提交
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.