New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Most pre-commit hooks broken after OS upgrade to 20.04 #1427
Comments
that's strange, it worked fine for me when I upgrade from 18.04 -> 20.04 -- pre-commit has code to detect this and recreate environments even can you poke around in |
an |
and likely |
oh I know what happened, yeah I'll work on fixing this the python version changed, but since virtualenv 20.x the executable is just a symlink -- so the symlink was valid and the "healthy" check succeeded but site-packages was at a completely different path resulting in import errors |
My apologies, I didn't look at this before I tried blowing away the cache, removing it resolved it: Thanks! |
I did list the .cache directory if that's of any help: |
ok I'm able to reproduce this in docker, but only after doing a strange thing to teh system python -- but in theory it seems possible to end up in this case in some other way FROM ubuntu:bionic AS builder
RUN : \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
python3 \
python3-distutils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# I couldn't figure out how to force virtualenv to symlink to python3
# so this hack works :shrugs:
RUN mv /usr/bin/python3.6 /usr/bin/python3
ENV PATH=/venv/bin:$PATH
RUN : \
&& curl https://asottile.github.io/get-virtualenv.py | python3 - /venv \
&& pip install pre-commit
RUN : \
&& git clone https://github.com/asottile/astpretty /astpretty \
&& cd /astpretty \
&& echo 'default_language_version:' >> .pre-commit-config.yaml \
&& echo ' python: python3' >> .pre-commit-config.yaml \
&& pre-commit run --all-files
FROM ubuntu:focal AS final
RUN : \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gcc \
g++ \
git \
python3-dev \
python3-distutils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV PATH=/venv/bin:$PATH
RUN : \
&& curl https://asottile.github.io/get-virtualenv.py | python3 - /venv \
&& pip install pre-commit
COPY --from=builder /root/.cache/pre-commit /root/.cache/pre-commit
COPY --from=builder /astpretty /astpretty
RUN cd /astpretty && pre-commit run --all-files $ docker build -t test .
...
setup-cfg-fmt............................................................Failed
- hook id: setup-cfg-fmt
- exit code: 1
Traceback (most recent call last):
File "/root/.cache/pre-commit/repo_vb9lwwz/py_env-python3/bin/setup-cfg-fmt", line 5, in <module>
from setup_cfg_fmt import main
ModuleNotFoundError: No module named 'setup_cfg_fmt'
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1
Traceback (most recent call last):
File "/root/.cache/pre-commit/repokpzyv_r7/py_env-python3/bin/mypy", line 5, in <module>
from mypy.__main__ import console_entry
ModuleNotFoundError: No module named 'mypy'
The command '/bin/sh -c cd /astpretty && pre-commit run --all-files' returned a non-zero code: 1 |
That sounds like a thing that I would do. :) |
thanks for the issue, this has been released as part of v2.4.0 🎉 |
I get the same behavior from all my hooks (except pyupgrade)
I tried uninstalling and reinstalling all those pip packages (both globally and with --user):
sudo pip install pylint pytest flake8 mypy pre-commit isort black
The text was updated successfully, but these errors were encountered: