I believe the only current r/w operation on the store is to mark the configuration as used. this could be skipped and installations could raise an error
$ docker run --rm -ti -e PRE_COMMIT_HOME=/pc --workdir /src -v ~/workspace/pre-commit:/src:ro -v $PWD/pc:/pc:rw $IMG pre-commit install-hooks
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://gitlab.com/pycqa/flake8.
[INFO] Initializing environment for https://gitlab.com/pycqa/flake8:flake8-typing-imports==1.6.0.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-autopep8.
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit.
[INFO] Initializing environment for https://github.com/asottile/pyupgrade.
[INFO] Initializing environment for https://github.com/asottile/reorder_python_imports.
[INFO] Initializing environment for https://github.com/asottile/add-trailing-comma.
[INFO] Initializing environment for https://github.com/asottile/setup-cfg-fmt.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-mypy.
[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] Installing environment for https://gitlab.com/pycqa/flake8.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/mirrors-autopep8.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/asottile/pyupgrade.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/asottile/reorder_python_imports.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/asottile/add-trailing-comma.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/asottile/setup-cfg-fmt.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/mirrors-mypy.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
$ docker run --rm -ti -e PRE_COMMIT_HOME=/pc --workdir /src -v ~/workspace/pre-commit:/src:ro -v $PWD/pc:/pc:ro $IMG pre-commit run --all-files
An unexpected error has occurred: OperationalError: attempt to write a readonly database
Check the log at /pc/pre-commit.log
Traceback (most recent call last):
File "/venv/lib/python3.8/site-packages/pre_commit/error_handler.py", line 56, in error_handler
yield
File "/venv/lib/python3.8/site-packages/pre_commit/main.py", line 351, in main
store.mark_config_used(args.config)
File "/venv/lib/python3.8/site-packages/pre_commit/store.py", line 228, in mark_config_used
db.execute('INSERT OR IGNORE INTO configs VALUES (?)', (path,))
sqlite3.OperationalError: attempt to write a readonly database
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/venv/bin/pre-commit", line 8, in <module>
sys.exit(main())
File "/venv/lib/python3.8/site-packages/pre_commit/main.py", line 404, in main
raise AssertionError(
File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/venv/lib/python3.8/site-packages/pre_commit/error_handler.py", line 64, in error_handler
_log_and_exit(msg, e, traceback.format_exc())
File "/venv/lib/python3.8/site-packages/pre_commit/error_handler.py", line 24, in _log_and_exit
with open(log_path, 'wb') as log:
OSError: [Errno 30] Read-only file system: '/pc/pre-commit.log'
(mostly as a hardening measure for pre-commit.ci)
I believe the only current r/w operation on the store is to mark the configuration as used. this could be skipped and installations could raise an error
(I might be missing something)
easiest reproduction is via docker:
may also need another place to put
pre-commit.logas well 🤔