Repository navigation
Closed
Description
The pre-commit flake8 check is failing without any error message for me. It just says Failed.
pre-commit runtests: commands[1] | pre-commit run --all-files
Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Check docstring is first.................................................Passed
Check that executables have shebangs.................(no files to check)Skipped
Check for merge conflicts................................................Passed
Check Yaml...............................................................Passed
Debug Statements (Python)................................................Passed
Fix double quoted strings................................................Passed
Flake8...................................................................Failed
Check for added large files..............................................Passed
Check for byte-order marker..............................................Passed
Fix python encoding pragma...............................................Passed
Fix requirements.txt.....................................................Passed
Reorder python imports...................................................Passed
autopep8.................................................................Passed
pyupgrade................................................................Passed
ERROR: InvocationError: '/nail/home/drolando/pg/python/yelp_zipkin_utils/.tox/pre-commit/bin/pre-commit
run --all-files'
_______________________________________________ summary _______________________________________________
py27: commands succeeded
py36: commands succeeded
py37: commands succeeded
ERROR: pre-commit: commands failed
Makefile:4: recipe for target 'test' failed
make: *** [test] Error 1
If I source the virtualenv and run flake8 everything works though, so there seems to be something special with the way pre-commit runs it.
drolando@dev128-uswest1adevc yelp_zipkin_utils (git master) ✓
~> source .tox/pre-commit/bin/activate
drolando@dev128-uswest1adevc yelp_zipkin_utils (git master) ✓
~> flake8
drolando@dev128-uswest1adevc yelp_zipkin_utils (git master) ✓
~>
~> cat .pre-commit-config.yaml
repos:
- repo: [email protected]:mirrors/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: double-quote-string-fixer
- id: flake8
- id: check-added-large-files
- id: check-byte-order-marker
- id: fix-encoding-pragma
- id: requirements-txt-fixer
~> cat tox.ini | grep -A 3 flake8
[flake8]
ignore =
exclude = .git,.tox,docs,virtualenv_run
filename = *.py
(pre-commit)
The interesting thing is that it works fine if I use python3.6, it only seems to fail if I use python3.7 (3.7.5). @asottile have you seen this issue before? Any suggestion on how to debug it otherwise? Adding -v doesn't print anything useful...
Metadata
Metadata
Assignees
Labels
No labels
Activity
asottile commentedon Dec 17, 2019
this means that flake8 is returning no output and exiting nonzero -- someone else hit this before in the tracker though: pre-commit/pre-commit#1221
it ended up being that python had upgraded out from under them and the interpreter was only partially functioning (but still passed the
healthy()check?)perhaps you can run the commands that I requested there and actually produce the output / get to a more helpful answer ;)
asottile commentedon Dec 17, 2019
also note that you're using the deprecated flake8 hook
drolando commentedon Dec 17, 2019
If I run
for f in $(find . -name '*.py' | grep -vE '.tox|.git'); do echo $f; pre-commit run flake8 --file $f; donethey all pass. It only breaks when using--all-files.flake8; echo $?returns 0 correctly, so not sure what's up with it.However
rm -rf ~/.cache/pre-commitworked and now the flake8 hook is working fine. 🤷♂asottile commentedon Dec 17, 2019
you should use
pre-commit cleaninstead for thatrm -rfcommand -- but now our reproduction is gone :( -- I was hoping you'd try some of the commands against theflake8cache executable in that issue before deleting :(ah well, nothing we can do here now
drolando commentedon Dec 17, 2019
@asottile I actually run
mv ~/.cache/pre-commit ~/.cache/pre-commit.bakso we should be able to get back the old statedrolando commentedon Dec 17, 2019
oh but there are 150 different folders in there named with a sha, so now I don't know anymore which one was it :(
asottile commentedon Dec 17, 2019
there's a little sqlite database you can poke at
db.db-- the format is intentionally undocumented implementation detail but you may be able to poke around at it a bit (it's basically keyed off of the repository name andlanguage_version)drolando commentedon Dec 17, 2019
Swapping the folders again did the trick, now I have again the broken pre-commit env.
What did you want me to try?
asottile commentedon Dec 17, 2019
I'm curious what invoking the
flake8executable inside the particular cached folder results in, you canpre-commit gcto clean up any unused ones and then you should be able to find it via$ ls ~/.cache/pre-commit/repo*/py_env*/bin/flake8you can cross reference it against the database in
~/.cache/pre-commit/db.dbthe (probably) important things to look at are the difference between
python3.7 --versionandpath/to/env/bin/python --version(from the hook environments)as well as trying the env flake8 with
-vvvdrolando commentedon Dec 17, 2019
Yup the python versions don't match
And running flake8 from that virtualenv segfaults
Looks like python 3.7.5 was backported to bionic in November http://changelogs.ubuntu.com/changelogs/pool/universe/p/python3.7/python3.7_3.7.5-2~18.04/changelog. I thought ubuntu would never update versions outside of a new releast though...
asottile commentedon Dec 17, 2019
yeah the ubuntu maintainer has been doing some very strange things with this LTS release 🤔
they've continued to update the 3.7.x packages and even introduced a 3.8 package, it's been quite a lot more work to keep up with these surprises in deadsnakes :(
but yeah I guess that explains it, given that segmentation fault. I'm kind of surprised the
healthy()check passes, but perhaps it doesn't import the proper modules to cause a segfaultcould you strace it and attach a log? that might be helpful for improving the
healthy()check inpre-commitsuch that these are automagically rebuiltdrolando commentedon Dec 17, 2019
strace: https://i.fluffy.cc/fp07X05FnxqQ7QtGsgpcxRPnDFflgZkW.html
The python executable is not entirely broken, I am able to get a shell...
asottile commentedon Dec 17, 2019
huh yeah seems it only ends up segfaulting after trying to do multiprocessing things -- probably not something that can be cheaply detected in
healthy():/