Migration mode does not work on Windows if legacy script starts with `#!/bin/sh`
See original GitHub issueRepro steps:
- Create a git repo on windows, install git-lfs. It will add pre-push hook with this content:
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.\n"; exit 2; }
git lfs pre-push "$@"
- Install pre-commit and call
pre-commit install -t pre-push
It will renamepre-push
topre-push.legacy
, command output:
pre-commit installed at .git\hooks\pre-commit
Running in migration mode with existing hooks at .git\hooks\pre-push.legacy
Use -f to use only pre-commit.
pre-commit installed at .git\hooks\pre-push
- Try pushing with
git push
It will fail with:
An unexpected error has occurred: ExecutableNotFoundError: Executable `/bin/sh` not found
Check the log at C:\Users\<username>\.cache\pre-commit\pre-commit.log
error: failed to push some refs to <repo url>
Expected: git push will work and will successfully call legacy git-lfs hook
Actual: git push fails
Log file content:
version information
pre-commit version: 2.7.1
sys.version:
3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]
sys.executable: d:\envs\polymer\python.exe
os.name: nt
sys.platform: win32
error information
An unexpected error has occurred: ExecutableNotFoundError: Executable `/bin/sh` not found
Traceback (most recent call last):
File "d:\envs\polymer\lib\site-packages\pre_commit\error_handler.py", line 63, in error_handler
yield
File "d:\envs\polymer\lib\site-packages\pre_commit\main.py", line 369, in main
args=args.rest[1:],
File "d:\envs\polymer\lib\site-packages\pre_commit\commands\hook_impl.py", line 211, in hook_impl
retv, stdin = _run_legacy(hook_type, hook_dir, args)
File "d:\envs\polymer\lib\site-packages\pre_commit\commands\hook_impl.py", line 42, in _run_legacy
cmd = normalize_cmd((legacy_hook, *args))
File "d:\envs\polymer\lib\site-packages\pre_commit\parse_shebang.py", line 82, in normalize_cmd
exe = normexe(cmd[0])
File "d:\envs\polymer\lib\site-packages\pre_commit\parse_shebang.py", line 61, in normexe
_error('not found')
File "d:\envs\polymer\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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
running pre-commit python package in Windows gives ...
I work in Windows where my teammates work on Macs. It looks like precommit is trying to reference the /bin/sh script which is...
Read more >Troubleshooting Windows Subsystem for Linux | Microsoft Learn
Additionally, if you are using an ARM64 device and running this command from PowerShell, you will receive this error. Instead run wsl.exe from ......
Read more >Move Legacy Content - Behind the Blackboard!
Execute movecontent script from migration archive to do the actual move. This will run in the background on Linux, and foreground on Windows...
Read more >Cluster node initialization scripts | Databricks on AWS
Legacy global: run on every cluster. They are less secure than the new global init script framework, silently ignore failures, and cannot ......
Read more >Candy: Legacy boot does not work - Freezes with CTRL-L
In both of these cases, keyboard input does not work anymore and I have to power ... merge the two: dd if=seabios.cbfs of=bios.bin...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
use
/usr/bin/env sh
/bin/sh
is not portableNever mind, the folder was hidden … all good … thanks