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

.git directory included when pre-commit hooks are installed #25

Open
Alex-JG3 opened this issue Mar 13, 2023 · 0 comments
Open

.git directory included when pre-commit hooks are installed #25

Alex-JG3 opened this issue Mar 13, 2023 · 0 comments

Comments

@Alex-JG3
Copy link
Contributor

Summary

When I try to remove a virtual environment where pre-commit-hooks has been installed with something like rm -r .venv, I get a few permission errors due to the .git folder being included when pre-commit-hooks is installed. For example

$ rm -r .venv
override r--r--r-- alex.gregory/staff for .venv/src/pre-commit-hooks/.git/objects/pack/pack-44993e939eb30aa8a7a25bf5283e58ed3ce0d755.pack? override r--r--r-- alex.gregory/staff for .venv/src/pre-commit-hooks/.git/objects/pack/pack-44993e939eb30aa8a7a25bf5283e58ed3ce0d755.idx? rm: .venv/src/pre-commit-hooks/.git/objects/pack: Permission denied
rm: .venv/src/pre-commit-hooks/.git/objects: Permission denied
rm: .venv/src/pre-commit-hooks/.git: Permission denied
rm: .venv/src/pre-commit-hooks: Permission denied
rm: .venv/src: Permission denied
rm: .venv: Permission denied

Would it be possible to remove the .git directory when installing pre-commit-hooks?

Minimal Example

Create a directory with following simple structure.

root_dir
├── pyproject.toml
└── test_project
    └── __init__.py

The pyproject.toml is as follows.

[tool.poetry]
name = "test-project"
version = "0.1.0"
description = ""
authors = ["Alex Gregory <[email protected]>"]
packages = [{include = "test_project"}]

[tool.poetry.dependencies]
python = "^3.9"
pre-commit = "^3.1.1"
hooks = {git = "https://github.com/stfc/pre-commit-hooks"}


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

The__init__.py is empty.

Install the test_project package.

$ cd root_dir
$ poetry install
Creating virtualenv test-project in /Users/alex.gregory/Documents/test_project/.venv
Installing dependencies from lock file

Package operations: 118 installs, 1 update, 0 removals

  • Installing six (1.16.0)
  • Installing attrs (22.2.0)
  • Installing platformdirs (3.1.1)
  • Installing pyrsistent (0.19.3)
  • Installing python-dateutil (2.8.2)
  • Installing traitlets (5.9.0)
  • Installing zipp (3.15.0)
  • Installing arrow (1.2.3)
  • Installing fastjsonschema (2.16.3)
  • Installing importlib-metadata (6.0.0)
  • Installing jsonschema (4.17.3)
  • Installing jupyter-core (5.2.0)
  • Installing pycparser (2.21)
  • Installing pyzmq (25.0.1)
  • Installing tornado (6.2)
  • Installing cffi (1.15.1): Installing...
  • Installing fqdn (1.5.1): Pending...
  • Installing cffi (1.15.1)
  • Installing fqdn (1.5.1)
  • Installing idna (3.4)
  • Installing isoduration (20.11.0)
  • Installing jsonpointer (2.3)
  • Installing jupyter-client (8.0.3)
  • Installing markupsafe (2.1.2)
  • Installing nbformat (5.7.3)
  • Installing ptyprocess (0.7.0)
  • Installing rfc3339-validator (0.1.4)
  • Installing rfc3986-validator (0.1.1)
  • Installing soupsieve (2.4)
  • Installing uri-template (1.2.0)
  • Installing webcolors (1.12)
  • Installing webencodings (0.5.1)
  • Installing argon2-cffi-bindings (21.2.0): Installing...
  • Installing asttokens (2.2.1): Installing...
  • Installing argon2-cffi-bindings (21.2.0)
  • Installing asttokens (2.2.1)
  • Installing beautifulsoup4 (4.11.2)
  • Installing bleach (6.0.0)
  • Installing defusedxml (0.7.1)
  • Installing executing (1.2.0)
  • Installing jinja2 (3.1.2)
  • Installing jupyterlab-pygments (0.2.2)
  • Installing mistune (2.0.5)
  • Installing nbclient (0.7.2)
  • Installing packaging (23.0)
  • Installing pandocfilters (1.5.0)
  • Installing parso (0.8.3)
  • Installing pure-eval (0.2.2)
  • Installing pygments (2.14.0)
  • Installing python-json-logger (2.0.7)
  • Installing pyyaml (6.0)
  • Installing sniffio (1.3.0)
  • Installing terminado (0.17.1)
  • Installing tinycss2 (1.2.1)
  • Installing wcwidth (0.2.6)
  • Installing anyio (3.6.2): Installing...
  • Installing appnope (0.1.3): Installing...
  • Installing anyio (3.6.2)
  • Installing appnope (0.1.3)
  • Installing argon2-cffi (21.3.0)
  • Installing backcall (0.2.0)
  • Installing decorator (5.1.1)
  • Installing jedi (0.18.2)
  • Installing jupyter-events (0.6.3)
  • Installing jupyter-server-terminals (0.4.4)
  • Installing matplotlib-inline (0.1.6)
  • Installing nbconvert (7.2.9)
  • Installing pexpect (4.8.0)
  • Installing pickleshare (0.7.5)
  • Installing prometheus-client (0.16.0)
  • Installing prompt-toolkit (3.0.38)
  • Installing send2trash (1.8.0)
  • Installing stack-data (0.6.2)
  • Installing websocket-client (1.5.1)
  • Installing comm (0.1.2)
  • Installing debugpy (1.6.6)
  • Installing ipython (8.11.0)
  • Installing jupyter-server (2.4.0)
  • Installing nest-asyncio (1.5.6)
  • Installing psutil (5.9.4)
  • Installing aiofiles (22.1.0)
  • Installing aiosqlite (0.18.0)
  • Installing certifi (2022.12.7)
  • Installing charset-normalizer (3.1.0)
  • Installing ipykernel (6.21.3)
  • Installing ipython-genutils (0.2.0)
  • Installing notebook-shim (0.2.2)
  • Installing urllib3 (1.26.15)
  • Installing y-py (0.5.9)
  • Installing babel (2.12.1)
  • Installing json5 (0.9.11)
  • Installing jupyter-server-fileid (0.8.0)
  • Installing jupyter-ydoc (0.2.3)
  • Installing nbclassic (0.5.3)
  • Installing requests (2.28.2)
  • Installing ypy-websocket (0.8.2)
  • Installing jupyter-server-ydoc (0.6.1)
  • Installing jupyterlab-server (2.20.0)
  • Installing lazy-object-proxy (1.9.0)
  • Installing notebook (6.5.3)
  • Installing tomli (2.0.1)
  • Installing typing-extensions (4.5.0)
  • Installing wrapt (1.15.0)
  • Installing astroid (2.13.5)
  • Installing dill (0.3.6)
  • Installing distlib (0.3.6)
  • Installing filelock (3.9.0)
  • Installing isort (5.12.0)
  • Installing jupyterlab (3.6.1)
  • Installing mccabe (0.7.0)
  • Installing mypy-extensions (0.4.4)
  • Updating setuptools (67.2.0 -> 67.6.0)
  • Installing tomlkit (0.11.6)
  • Installing cfgv (3.3.1)
  • Installing identify (2.5.20)
  • Installing jupyterlab-code-formatter (1.5.3)
  • Installing mypy (0.991)
  • Installing nodeenv (1.7.0)
  • Installing pylint (2.15.10)
  • Installing regex (2021.11.10)
  • Installing requirements-parser (0.2.0)
  • Installing toml (0.10.2)
  • Installing virtualenv (20.21.0)
  • Installing hooks (0.3.4 d3afee3)
  • Installing pre-commit (3.1.1)

Installing the current project: test-project (0.1.0)

Then remove the .venv folder where the packages are installed.

$ rm -r .venv
override r--r--r-- alex.gregory/staff for .venv/src/pre-commit-hooks/.git/objects/pack/pack-44993e939eb30aa8a7a25bf5283e58ed3ce0d755.pack?
override r--r--r-- alex.gregory/staff for .venv/src/pre-commit-hooks/.git/objects/pack/pack-44993e939eb30aa8a7a25bf5283e58ed3ce0d755.idx?
rm: .venv/src/pre-commit-hooks/.git/objects/pack: Permission denied
rm: .venv/src/pre-commit-hooks/.git/objects: Permission denied
rm: .venv/src/pre-commit-hooks/.git: Permission denied
rm: .venv/src/pre-commit-hooks: Permission denied
rm: .venv/src: Permission denied
rm: .venv: Permission denied

We get some permission errors to do with the pre-commit .git directory.

Temporary Solutions

  • The .venv folder can be removed with rm -rf .venv however avoiding having to use the --force option would be preferable.

  • Remove the .git folder using something like rm -rf .venv/src/pre-commit-hooks/.git which then lets you remove the .venv folder with rm -r .venv without the --force option which is slightly better.

Proposed Solution

Find a way to avoid including the .git when installing as pre-commit-hooks.

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

No branches or pull requests

1 participant