Skip to content
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

pre-commit hook not working due to isort PEX failure. #7436

Closed
thoward opened this issue Mar 25, 2019 · 5 comments
Closed

pre-commit hook not working due to isort PEX failure. #7436

thoward opened this issue Mar 25, 2019 · 5 comments
Labels

Comments

@thoward
Copy link
Contributor

thoward commented Mar 25, 2019

I'm trying to file a PR and have installed the precommit hooks locally. I'm running into a problem where the hook is failing with an obscure error:

                     Failed to execute PEX file, missing macosx_10_13_x86_64-cp-27-cp27m compatible dependencies for:
                     isort

FAILURE: /Users/thoward/.pyenv/shims/python3.6 /Users/thoward/.cache/pants/python/CPython-3.6.0/d6bcba436bdefbc27a69dd880d6ee5716e004764/isort-c201e856817dc9ae802d18e3ec45a3bfa4c2ac11.pex --check-only <... snip: lots of files ...> ... exited non-zero (1). 

I have Python 3.6 installed via pyenv and it's working as expected for everything else. This seems like some kind of platform-specific issue w/ the isort PEX that's being used. Would really love to get this working so I can file a couple PRs, but currently at a loss of how to resolve.

@stuhood
Copy link
Member

stuhood commented Mar 27, 2019

@thoward : You can pass PEX_VERBOSE=9 to get some more info from pex about why it's not finding anything there. I'm also not sure how pyenv works in this case: when running pants from source, the pants script creates a venv to operate in... presumably creating a venv inside a pyenv environment should work?

Oh... having typed all that out, I think I might see the issue. isort is looking to check some code as python2. Does your pyenv not have python2 inside of it? cc @Eric-Arellano

@Eric-Arellano
Copy link
Contributor

Eric-Arellano commented Mar 27, 2019

Hi @thoward - thanks for working on some PRs and sorry this is interfering!

To confirm, you are running Pants through the ./pants script we have in this repository, rather than the one that we distribute to the public at https://github.com/pantsbuild/setup/blob/gh-pages/pants, correct? The scripts are different in how they handle virtual envs.

Could you please rm -rf ~/.cache/pants/python_cache/interpreters build-support/pants_dev_deps.venv build-support/pants_dev_deps.py{2,3}.venv? Then try running ./pants again.

@thoward
Copy link
Contributor Author

thoward commented Mar 29, 2019

I was able to get around this by uninstalling Python 3.6.0 from pyenv (leaving only 2.7.8 available), setting PY=python2, which got isort working. Then the style check stage was bombing, with a failure to find an interpreter that matched the constraints, so I commented out my /etc/pexrc and was able to get through that stage. These workarounds got me through the precommit hooks and I was able to commit the changes and file a PR...

@Eric-Arellano Yup, using the ./pants in the repo. Specifically, I installed the precommit hook from buildsupport dir and these commands are running when I attempt to run git commit. Removing cached interpreters didn't have a noticeable impact. I seem to get caught between things that work under 2.x and things that work under 3.x and the only way I've found to get through all the precommit steps is to lower everything to python 2 compat and remove python3 from the picture entirely.

@Eric-Arellano
Copy link
Contributor

Ah that complicates things that you have /etc/pexrc. There was an upstream Pex issue that resulted in the error "failed to find incompatible interpreters". We are in the process of upgrading the Pex version used by Pants (#7186), so that issue should be fixed soon.

Now that you have Pexrc commented out, you should be able to re-install 3.6 from Pyenv, and ./pants / build-support/bin/pre-commit.sh should work. Let me know please when you have a moment if this works - trying to confirm this issue is already known.

Also, rather than calling PY=python2 ./pants, you can call ./pants2 - it does the same thing for less typing.

@jsirois
Copy link
Contributor

jsirois commented Mar 16, 2020

This was almost certainly #7816. I'll close this issue and track the solution over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants