Uninstalled pre-commit preventing 'git commit' (pipenv)
Asked Answered
B

2

7

I recently uninstalled pre-commit from my environment. I performed the following in pipenv:

pipenv --rm
<deleted Pipfile and Pipfile.lock>
pipenv install -r requirements.txt 

I ensured that the pre-commit module was no longer in the requirements.txt. When I make a git commit I get:

~/my_project/.venv/bin/python: No module named pre_commit

This is preventing me from committing, and I have no idea where this is coming from, since pre-commit is not being installed. Further, the traceback path specified is pointing to python and not python3. What am I missing?

Baleen answered 23/3, 2022 at 12:28 Comment(1)
I suppose its called in your pre-commit hook.Snowwhite
L
7

There are still pre-commit hooks installed in your git repository. You can remove them by simply deleting .git/hooks/pre-commit in you repository, after which pre-commit won't be called anymore when commiting.

Lager answered 23/3, 2022 at 12:31 Comment(2)
thanks, that was it. I just deleted two files with 'rm pre-commit*' in .git/hooks/Baleen
I have a new repo without hooks and I still can't commit. Sorry, this is bad by design that upon uninstalling all dependent hooks are still activeHooked
B
19

typically the way to remove the hook installed by pre-commit install is to call pre-commit uninstall -- though if you've removed pre-commit from your system you can remove the hook scripts manually

you can usually find them by doing:

grep pre-commit.com .git/hooks/*

as that marker is listed in the hook files

from there you can delete them:

grep -l pre-commit.com .git/hooks/* | xargs rm

disclaimer: I made pre-commit

Bioscope answered 23/3, 2022 at 14:41 Comment(0)
L
7

There are still pre-commit hooks installed in your git repository. You can remove them by simply deleting .git/hooks/pre-commit in you repository, after which pre-commit won't be called anymore when commiting.

Lager answered 23/3, 2022 at 12:31 Comment(2)
thanks, that was it. I just deleted two files with 'rm pre-commit*' in .git/hooks/Baleen
I have a new repo without hooks and I still can't commit. Sorry, this is bad by design that upon uninstalling all dependent hooks are still activeHooked

© 2022 - 2024 — McMap. All rights reserved.