swincas / cookies-n-code

A repo for code review sessions at CAS
http://astronomy.swin.edu.au/
MIT License
30 stars 34 forks source link

Pip and OzStar #49

Open jacobseiler opened 5 years ago

jacobseiler commented 5 years ago

Howdy Y'all,

I'm trying to use the package pre-commit which runs a set of scripts or checking on every commit that you make. I am having issues with compatibility of Pip on OzStar.

Here are the steps I'm taking. If possible, could someone go to a repository that is Git-controlled on OzStar and attempt to follow these steps?

$ pip install pre_commit
$ pre-commit --version
pre-commit 1.18.1

This installs the package as expected and everything is hunky dory.

$ pre-commit install

This installs the hooks required.

To run, pre-commit requires a .pre-commit-config.yaml file to tell it what checks it should run on every commit. Here is my .yaml file that I am using.

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v1.2.3
    hooks:
    - id: flake8

Basically, on every commit, flake8 will run and check Pep8 compliance (#EllertIsHappy).

At this point, pre-commit should be able to run. We can check this with

$ pre-commit

This is where I get the crash.

(py3.7) [jseiler@farnarkle1 rsage]$ pre-commit
[INFO] Stashing unstaged files to /home/jseiler/.cache/pre-commit/patch1565761019.
[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] Restored changes from /home/jseiler/.cache/pre-commit/patch1565761019.
An unexpected error has occurred: CalledProcessError: Command: ('/home/jseiler/.cache/pre-commit/repo6j0kyldw/py_env-python3.7/bin/python', '/home/jseiler/.cache/pre-commit/repo6j0kyldw/py_env-python3.7/bin/pip', 'install', '.')
Return code: 1
Expected return code: 0
Output: 
    Processing /home/jseiler/.cache/pre-commit/repo6j0kyldw

Errors: 
    Could not install packages due to an EnvironmentError: [('/home/jseiler/.cache/pre-commit/repo6j0kyldw/.git/objects/pack/pack-e19eaf5d2a40d7a63ef1a73ac1a6f2934cdd7e5c.pack', '/fred/oz004/jseiler/pip_tmp/pip-req-build-ulrdsljz/.git/objects/pack/pack-e19eaf5d2a40d7a63ef1a73ac1a6f2934cdd7e5c.pack', "[Errno 13] Permission denied: '/fred/oz004/jseiler/pip_tmp/pip-req-build-ulrdsljz/.git/objects/pack/pack-e19eaf5d2a40d7a63ef1a73ac1a6f2934cdd7e5c.pack'"), ('/home/jseiler/.cache/pre-commit/repo6j0kyldw/.git/objects/pack/pack-e19eaf5d2a40d7a63ef1a73ac1a6f2934cdd7e5c.idx', '/fred/oz004/jseiler/pip_tmp/pip-req-build-ulrdsljz/.git/objects/pack/pack-e19eaf5d2a40d7a63ef1a73ac1a6f2934cdd7e5c.idx', "[Errno 13] Permission denied: '/fred/oz004/jseiler/pip_tmp/pip-req-build-ulrdsljz/.git/objects/pack/pack-e19eaf5d2a40d7a63ef1a73ac1a6f2934cdd7e5c.idx'")]

Because pre-commit is trying to boot up a Virtual Env using Pip, there is a permission problem. Normally, you would circumvent this using the --user flag but since this command isn't being run by me in the command line, I can't add that flag!

I have attempted to fix the issues by setting the TMPDIR environment variable to /fred/oz004/jseiler/pip_tmp/ but alas it is still yelling at me.

Any insights would be welcome.

manodeep commented 5 years ago

Is there a verbose option for pre-commit?

I am not sure I see why the [Errno 13] Permission denied: is being generated - you should have write access to your own TMPDIR.

manodeep commented 5 years ago

The only StackOverflow thing that looks reasonable is this one: https://github.com/pre-commit/pre-commit/issues/413

jacobseiler commented 5 years ago

Yeah I'm unsure if the issue is with pre-commit, virtualenv or with pip itself. It's a tough thing to diagnose.