0

When I run run pre-commit it successfully runs black, isort, flake8, and pyupgrade, but it is unable to run the hooks installed from https://github.com/pre-commit/pre-commit-hooks.

However, I can see it downloaded the hooks and stored them in the cache.

$ find  $HOME/.cache/pre-commit/ | grep fix-byte-order-marker
/home/me/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/fix-byte-order-marker

$ find  $HOME/.cache/pre-commit/ | grep trailing-whitespace-fixer
/home/me/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/trailing-whitespace-fixer

$ find  $HOME/.cache/pre-commit/ | grep end-of-file-fixer
/home/me/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/end-of-file-fixer

How can I troubleshoot this further?

$ git commit -m "Test"
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/PyCQA/isort.
[INFO] Initializing environment for https://github.com/pycqa/flake8.
[INFO] Initializing environment for https://github.com/asottile/pyupgrade.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/psf/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/PyCQA/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pycqa/flake8.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/asottile/pyupgrade.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
check python ast.........................................................Failed
- hook id: check-ast
- exit code: 1

Executable `check-ast` not found

check for case conflicts.................................................Failed
- hook id: check-case-conflict
- exit code: 1

Executable `check-case-conflict` not found

check json...........................................(no files to check)Skipped
check for merge conflicts................................................Failed
- hook id: check-merge-conflict
- exit code: 1

Executable `check-merge-conflict` not found

check for broken symlinks............................(no files to check)Skipped
check toml...........................................(no files to check)Skipped
check yaml...........................................(no files to check)Skipped
debug statements (python)................................................Failed
- hook id: debug-statements
- exit code: 1

Executable `debug-statement-hook` not found

detect private key.......................................................Failed
- hook id: detect-private-key
- exit code: 1

Executable `detect-private-key` not found

fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1

Executable `end-of-file-fixer` not found

fix utf-8 byte order marker..............................................Failed
- hook id: fix-byte-order-marker
- exit code: 1

Executable `fix-byte-order-marker` not found

pretty format json...................................(no files to check)Skipped
trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1

Executable `trailing-whitespace-fixer` not found

black....................................................................Passed
isort....................................................................Passed
flake8...................................................................Passed
pyupgrade................................................................Passed

More information:

did you copy your home directory from another computer? No

did you recently upgrade your operating system? No

did you uninstall python3.8? No, it's installed in a conda venv

Version:

$ pre-commit --version
pre-commit 3.3.3

Config file:

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.2.0
    hooks:
    -   id: check-ast
    -   id: check-case-conflict
    # -   id: check-docstring-first
    -   id: check-json
    -   id: check-merge-conflict
    -   id: check-symlinks
    -   id: check-toml
    -   id: check-yaml
    -   id: debug-statements
    # -   id: destroyed-symlinks
    -   id: detect-private-key
    -   id: end-of-file-fixer
    -   id: fix-byte-order-marker
    -   id: pretty-format-json
    -   id: trailing-whitespace
        exclude: setup.cfg

-   repo: https://github.com/psf/black
    rev: 22.3.0
    hooks:
    -   id: black
        args: [--line-length=200]

-   repo: https://github.com/PyCQA/isort
    rev: 5.11.5
    hooks:
    -   id: isort
        args: [--line-length 200]

-   repo: https://github.com/pycqa/flake8
    rev: 4.0.1
    hooks:
    -   id: flake8 # Just check that the code is well-formed
        args: [--count, "--select=E9,F63,F7,F82", --show-source, --statistics, --max-line-length=200]

-   repo: https://github.com/asottile/pyupgrade
    rev: v2.32.1
    hooks:
    -   id: pyupgrade
        args: [--keep-percent-format, --py37-plus]

Script Heads:

$ head -n 3 .git/hooks/pre-commit
#!/usr/bin/env bash
# File generated by pre-commit: https://pre-commit.com
# ID: 138fd403232d2ddd5efb44317e38bf03

$ cd ~
$ find -name  end-of-file-fixer
./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/end-of-file-fixer

$ head -n 1 ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/end-of-file-fixer
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

$ /home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python
Python 3.8.17 (default, Jul  5 2023, 20:41:08)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

$ head -n 1 ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/*
==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/activate <==
# This file must be used with "source bin/activate" *from bash*

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/activate.csh <==
# This file must be used with "source bin/activate.csh" *from csh*.

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/activate.fish <==
# This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/activate.nu <==
# virtualenv activation module

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/activate.ps1 <==
$script:THIS_PATH = $myinvocation.mycommand.path

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/activate_this.py <==
"""

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-added-large-files <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-ast <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-builtin-literals <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-byte-order-marker <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-case-conflict <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-docstring-first <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-executables-have-shebangs <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-json <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-merge-conflict <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-shebang-scripts-are-executable <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-symlinks <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-toml <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-vcs-permalinks <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-xml <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/check-yaml <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/debug-statement-hook <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/destroyed-symlinks <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/detect-aws-credentials <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/detect-private-key <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/double-quote-string-fixer <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/end-of-file-fixer <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/file-contents-sorter <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/fix-byte-order-marker <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/fix-encoding-pragma <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/forbid-new-submodules <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/mixed-line-ending <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/name-tests-test <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/no-commit-to-branch <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/pip <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/pip3 <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/pip-3.8 <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/pip3.8 <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/pre-commit-hooks-removed <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/pretty-format-json <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/requirements-txt-fixer <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/sort-simple-yaml <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/trailing-whitespace-fixer <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/wheel <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/wheel3 <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/wheel-3.8 <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python

==> ./.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/wheel3.8 <==
#!/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/python
Steve
  • 1,250
  • 11
  • 25
  • 2
    did you copy your home directory from another computer? did you recently upgrade your operating system? did you uninstall python3.8? – anthony sottile Aug 01 '23 at 16:06
  • 2
    please show your configuration file as well and your pre-commit version – anthony sottile Aug 01 '23 at 16:06
  • Thanks for taking a look at this Anthony. Pre-commit is really a great tool. I updated the question with more information, version, config file. I have two RedHat Linux servers with nearly identical configurations. One works, the other cannot find some of the executables. The only difference I can think of is firewall differences, but I don't see any network errors and it looks like the executables were installed in the cache directory. Any recommendations appreciated. – Steve Aug 02 '23 at 14:59
  • can you show `head -1` of all of the executables involved? `pre-commit` and the ones in the environments at least. – anthony sottile Aug 02 '23 at 16:49
  • Thanks for continuing to help me Anthony. I added the script heads for pre-commit itself and all the scripts in the precommit cache. May I ask, how does pre-commit know where to look for the scripts in the cache? – Steve Aug 02 '23 at 18:38
  • there's a little sqlite database in `~/.cache/pre-commit` -- implementation details though. one other question (probably save off a copy of `~/.cache/pre-commit` first) -- does `pre-commit clean && pre-commit install-hooks` fix the problem? – anthony sottile Aug 02 '23 at 20:26
  • pre-commit clean && pre-commit install-hooks did not fix the problem. The database looks good to me: sqlite> select * from repos where repo="https://github.com/pre-commit/pre-commit-hooks"; https://github.com/pre-commit/pre-commit-hooks|v4.2.0|/home/rmsalpharexsvcprod/.cache/pre-commit/repoekuo4ooh Is there a way to enable verbose debug logging? – Steve Aug 03 '23 at 12:46
  • if you need debugging use a debugger – anthony sottile Aug 03 '23 at 13:31
  • Thanks again Anthony. Found something. I'm getting permission denied errors for the executables in the ~/.cache/pre-commit/repoekuo4ooh/py_env-python3.8/bin/ directory. The files do have the x attribute set. I will follow-up with my system admins. I think there may be a restriction on this server to disallow executables in the home file system. One last question for you Anthony. Is there a way to configure the location of the .cache/pre-commit directory to move it off the home file system? – Steve Aug 04 '23 at 11:05
  • yep -- https://pre-commit.com has information on that – anthony sottile Aug 04 '23 at 16:12

0 Answers0