Skip to content

pre-commit autoupdate yields "PermissionError: [WinError 32]" #2046

Closed
@lcnittl

Description

@lcnittl

describe your issue

Whenever I try to do an autoupdate of the pre-commit config, I get the following error. I tried to reinstall pre-commit, wipe the venv dir, upgrade pip etc. Running on Win10 and Python 3.9.6 - it has been working since recently, but I can not recall any substantial change on the system that might cause this behavior. Interestingly installing the hooks works fine.

Really no idea what causes this and how to fix it. Did I miss something?

PS C:\Users\myusername\repos\myrepo> pre-commit autoupdate
Updating https://github.com/pre-commit/pre-commit-hooks ... An unexpected error has occurred: PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\myusername\\AppData\\Local\\Temp\\tmpjwm58zbt'
Check the log at C:\Users\myusername\.cache\pre-commit\pre-commit.log

pre-commit --version

pre-commit 2.15.0

.pre-commit-config.yaml

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.0.1
    hooks:
      - id: check-case-conflict
      - id: check-merge-conflict
      - id: trailing-whitespace
        args: [--markdown-linebreak-ext=md]
      - id: end-of-file-fixer
      - id: check-yaml
  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v2.3.2
    hooks:
      - id: prettier

~/.cache/pre-commit/pre-commit.log (if present)

version information

pre-commit version: 2.15.0
sys.version:
    3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)]
sys.executable: C:\Users\myusername\.local\pipx\venvs\pre-commit\Scripts\python.exe
os.name: nt
sys.platform: win32

error information

An unexpected error has occurred: PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\myusername\\AppData\\Local\\Temp\\tmpjwm58zbt'
Traceback (most recent call last):
  File "c:\program files\python39\lib\shutil.py", line 620, in _rmtree_unsafe
    os.rmdir(path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\myusername\\AppData\\Local\\Temp\\tmpjwm58zbt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\myusername\.local\pipx\venvs\pre-commit\lib\site-packages\pre_commit\error_handler.py", line 65, in error_handler
    yield
  File "C:\Users\myusername\.local\pipx\venvs\pre-commit\lib\site-packages\pre_commit\main.py", line 357, in main
    return autoupdate(
  File "C:\Users\myusername\.local\pipx\venvs\pre-commit\lib\site-packages\pre_commit\commands\autoupdate.py", line 157, in autoupdate
    new_info = info.update(tags_only=tags_only, freeze=freeze)
  File "C:\Users\myusername\.local\pipx\venvs\pre-commit\lib\site-packages\pre_commit\commands\autoupdate.py", line 58, in update
    rev, frozen = exact, rev
  File "c:\program files\python39\lib\contextlib.py", line 124, in __exit__
    next(self.gen)
  File "C:\Users\myusername\.local\pipx\venvs\pre-commit\lib\site-packages\pre_commit\util.py", line 72, in tmpdir
    rmtree(tempdir)
  File "C:\Users\myusername\.local\pipx\venvs\pre-commit\lib\site-packages\pre_commit\util.py", line 265, in rmtree
    shutil.rmtree(path, ignore_errors=False, onerror=handle_remove_readonly)
  File "c:\program files\python39\lib\shutil.py", line 740, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "c:\program files\python39\lib\shutil.py", line 622, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "C:\Users\myusername\.local\pipx\venvs\pre-commit\lib\site-packages\pre_commit\util.py", line 262, in handle_remove_readonly
    func(path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\myusername\\AppData\\Local\\Temp\\tmpjwm58zbt'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions