question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lcnittlcommented, Sep 13, 2021

git was the key word. I apparently recently upgraded it, and enabled the experimental built-in file system monitor (cf. screenshot).

image

Removing that setting during a reinstall fixed the issue.

Thank you for the - very quick - support!

Not sure if this is something that has to be fixed here - as the feature is experimental, I think it is rather on git’s side. So this issue might be closed as resolved.

0reactions
lcnittlcommented, Sep 13, 2021

To me it seems like a yes:

From https://newreleases.io/project/github/git-for-windows/git/release/v2.31.0.windows.1 :

Git for Windows now ships with an experimental built-in file-system monitor, without the need to install Watchman and setting core.fsmonitor. It can be turned on by setting both feature.manyFiles=true and feature.experimental=true (or directly, via core.useBuiltinFSMonitor=true).

So I assume adding those config settings on a repo level with false should disable that feature?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[winerror 32] - You.com | The AI Search Engine You Control
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...
Read more >
PermissionError [WinError 32] The process cannot access the ...
I'm trying to delete a file, but it's telling me I got a permission error. Does anyone know how I could fix this?...
Read more >
how to install express in console Code Example
... Could not install packages due to an EnvironmentError: [WinError 32] The process cannot access the file because it is being used by...
Read more >
W3layouts cms exploit - Weebly
'charmap' codec can't decode byte 0x9d in position 3499 'chromedriver_win32' executable may have wrong permissions. 'compose' is not exported from ...
Read more >
2.09 MB - Hugging Face
N X S core S chedule a bove g ree u fa Ġc ube cl ang Ġun able 01 5 32 0 20...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found