2

I have been asked to run the following command within my git repo in order to install pre-commit:

pre-commit install --hook-type commit-msg

However when attempting to commit code using GitKraken i'm getting the following error, this is on Windows 10.

### version information

pre-commit version: 2.19.0
git --version: git version 2.35.1.windows.2
sys.version:
    3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
sys.executable: C:\python39\python.exe
os.name: nt
sys.platform: win32

### error information

An unexpected error has occurred: ExecutableNotFoundError: Executable `/bin/bash` not found

Traceback (most recent call last):
  File "C:\python39\lib\site-packages\pre_commit\error_handler.py", line 73, in error_handler
    yield
  File "C:\python39\lib\site-packages\pre_commit\main.py", line 361, in main
    return hook_impl(
  File "C:\python39\lib\site-packages\pre_commit\commands\hook_impl.py", line 232, in hook_impl
    retv, stdin = _run_legacy(hook_type, hook_dir, args)
  File "C:\python39\lib\site-packages\pre_commit\commands\hook_impl.py", line 42, in _run_legacy
    cmd = normalize_cmd((legacy_hook, *args))
  File "C:\python39\lib\site-packages\pre_commit\parse_shebang.py", line 82, in normalize_cmd
    exe = normexe(cmd[0])
  File "C:\python39\lib\site-packages\pre_commit\parse_shebang.py", line 61, in normexe
    _error('not found')
  File "C:\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/bash` not found
// .pre-commit-config.yaml

ci:
  skip:
    - actionlint

repos:
  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
    rev: v8.0.0
    hooks:
      - id: commitlint
        stages: [commit-msg]
        additional_dependencies: ['commitlint-plugin-jira-rules', 'commitlint-config-jira']
  # - repo: https://github.com/editorconfig-checker/editorconfig-checker.python
  #   rev: 2.4.0
  #   hooks:
  #     - id: editorconfig-checker
  - repo: https://github.com/rhysd/actionlint
    rev: v1.6.12
    hooks:
      - id: actionlint
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.2.0
    hooks:
      - id: check-merge-conflict

How can I solve this, attempted to do a Google Search but to not success.

6
  • show your configuration Commented May 20, 2022 at 17:16
  • @AnthonySottile Didn't think it would be a config issue as its more of an issue with the tool running. Updated my post. Commented May 23, 2022 at 8:37
  • show the full output and the command you ran Commented May 23, 2022 at 20:53
  • @AnthonySottile Updated with full error log Commented May 24, 2022 at 7:41
  • If you are on Windows, you probably don't have /bin/bash. If you have Bash installed somewhere, update the path to point to the correct location. Commented May 24, 2022 at 7:46

1 Answer 1

3

Found the solution, just had to delete .git/hooks/pre-commit.legacy and then reinstall, I also deleted .git/hooks/pre-commit just to be sure before installing again.

Sign up to request clarification or add additional context in comments.

Did not fix it for me
rm .git/hooks/pre-commit.legacy fixed it for me in IntelliJ.

Your Answer

Draft saved
Draft discarded

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.