Repository: pre-commit/pre-commit

Issue:
pre-commit autoupdate (Windows), reports: `.pre-commit-hooks.yaml is not a file`
### search you tried in the issue tracker

is:issue "not a file"

### describe your issue

#### Summary
The last version I used successfully was `2.17.0` and `pre-commit 3.2.2, installed using Python 3.11.3`
 
#### Additional debugging tried
I tried manually specifying the `pre-commit-config.yaml` file, but I realise now that the error is related to the `pre-commit-`**hooks**`.yaml` file. ~~As this works outside of the tox env I suspect it is a bug.~~

I have the following tox file:

```ini
[tox]
minversion = 4.4.4
# We rely on the build agent configuration for setting the right Py version
envlist =
    py
skip_missing_interpreters = True
skipdist = True

[testenv]
usedevelop = True
extras =
    test
commands=
    git clean -xdf src tests
    pytest {posargs}
setenv =
    # Has problems with spaces in the path in Windows when using: {toxinidir}/constraints.txt
    PIP_CONSTRAINT=constraints.txt
    PIP_LOG={envdir}/pip.log
    PIP_DISABLE_PIP_VERSION_CHECK=1
passenv =
    PIP_*
    TWINE_*
allowlist_externals =
    git

[testenv:deps]
description = Update dependency lock files
deps =
    pip-tools >= 6.4.0
    pre-commit >= 2.13.0
commands =
    # pip-compile --upgrade -o constraints.txt pyproject.toml --extra docs --extra test --extra exe --strip-extras
    {envpython} -m pre_commit autoupdate --config="{toxinidir}{/}.pre-commit-config.yaml"
```

and this is the full output.
(For completeness I should mentioned that `MY_PROJECT` is actually a longer path)

```shell
> tox run -e deps                                                                                                                                                                                 
ROOT: provision> D:\dev\MY_PROJECT\.tox\.tox\Scripts\python.exe -m tox run -e deps
.pkg: _optional_hooks D:\dev\MY_PROJECT> python D:\dev\MY_PROJECT\.tox\.tox\Lib\site-packages\pyproject_api\_backend.py True hatchling.build
.pkg: get_requires_for_build_editable D:\dev\MY_PROJECT> python D:\dev\MY_PROJECT\.tox\.tox\Lib\site-packages\pyproject_api\_backend.py True hatchling.build
.pkg: build_editable D:\dev\MY_PROJECT> python D:\dev\MY_PROJECT\.tox\.tox\Lib\site-packages\pyproject_api\_backend.py True hatchling.build
deps: install_package D:\dev\MY_PROJECT> python -I -m pip install --force-reinstall --no-deps D:\dev\MY_PROJECT\.tox\.tmp\package\8\MY_PROJECT-1.0.1.dev49+ge471ddf.d20230502-py3-none-any.whl
deps: commands[0] D:\dev\MY_PROJECT> .tox\deps\Scripts\python.exe -m pre_commit autoupdate --config=D:\dev\MY_PROJECT\.pre-commit-config.yaml
[https://github.com/psf/black] 
=====> C:\Users\ADEHA~1\AppData\Local\Temp\tmp55jx9hj6\.pre-commit-hooks.yaml is not a file
[https://github.com/pre-commit/pre-commit-hooks] 
=====> C:\Users\ADEHA~1\AppData\Local\Temp\tmpkqy_t829\.pre-commit-hooks.yaml is not a file
[https://github.com/codespell-project/codespell.git] 
=====> C:\Users\ADEHA~1\AppData\Local\Temp\tmprw3q8l3b\.pre-commit-hooks.yaml is not a file
[https://github.com/charliermarsh/ruff-pre-commit] 
=====> C:\Users\ADEHA~1\AppData\Local\Temp\tmp27qxr3kd\.pre-commit-hooks.yaml is not a file
[https://github.com/adrienverge/yamllint.git] 
=====> C:\Users\ADEHA~1\AppData\Local\Temp\tmpssemasfd\.pre-commit-hooks.yaml is not a file
[https://github.com/pre-commit/mirrors-mypy.git] 
=====> C:\Users\ADEHA~1\AppData\Local\Temp\tmpasg5xk_r\.pre-commit-hooks.yaml is not a file
[https://github.com/asottile/pyupgrade] 
=====> C:\Users\ADEHA~1\AppData\Local\Temp\tmpo5pgj08h\.pre-commit-hooks.yaml is not a file
deps: exit 1 (26.53 seconds) D:\dev\MY_PROJECT> .tox\deps\Scripts\python.exe -m pre_commit autoupdate --config=D:\dev\MY_PROJECT\.pre-commit-config.yaml pid=40900
```

### pre-commit --version

3.3.0

### .pre-commit-config.yaml

```yaml
---
repos:
  - repo: https://github.com/psf/black
    rev: 23.3.0
    hooks:
      - id: black
        language_version: python3
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.4.0
    hooks:
      - id: end-of-file-fixer
      - id: trailing-whitespace
      - id: mixed-line-ending
      - id: check-byte-order-marker
      - id: check-executables-have-shebangs
      - id: check-merge-conflict
      - id: check-symlinks
      - id: check-vcs-permalinks
      - id: debug-statements
      - id: check-yaml
        files: .*\.(yaml|yml)$
  - repo: https://github.com/codespell-project/codespell
    rev: v2.2.4
    hooks:
      - id: codespell
        name: codespell
        description: Checks for common misspellings in text files.
        entry: codespell
        language: python
        types: [text]
        args: []
        require_serial: false
        additional_dependencies: []
  - repo: https://github.com/charliermarsh/ruff-pre-commit
    rev: 'v0.0.264'
    hooks:
      - id: ruff
        args: [--fix]
  - repo: https://github.com/adrienverge/yamllint
    rev: v1.31.0
    hooks:
      - id: yamllint
        files: \.(yaml|yml)$
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.2.0
    hooks:
      - id: mypy
        additional_dependencies:
          - .[docs,test]
  - repo: https://github.com/asottile/pyupgrade
    rev: v3.3.2
    hooks:
      - id: pyupgrade
        args: [--py38-plus]
```


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

_No response_


Discussion:
I am getting the same error when running 'pre-commit autoupdate'. i am able to do 'pre-commit run ...' I worked around the issue by running the autoupdate from an admin command prompt or PS.

was working fine yesterday with 3.2.2 but not with 3.3.0 this morning.

windows 11 python 3.10.11
> I am getting the same error when running 'pre-commit autoupdate'. i am able to do 'pre-commit run ...' I worked around the issue by running the autoupdate from an admin command prompt or PS.
> 
> was working fine yesterday with 3.2.2 but not with 3.3.0 this morning.
> 
> windows 11 python 3.10.11

Looks like I was mistaken on my workaround. It was pre-commit clean, followed by pre-commit run. elevated didn't matter.
if it works outside if tox then it's probably an issue with your tox configuration

perhaps try playing with passenv ?
Sorry, corrected my original post. That was a mistake from when I was first writing the issue. 

(I thought it worked outside of tox, but that was because I hadn't updated my version outside of tox. I confirm it now doesn't work neither in tox, nor outside) 
oddly enough I can sort of reproduce this -- but not with the test suite.  it appears to be a bug in git for windows so I'm reporting a bug there -- https://marc.info/?l=git&m=168303544023036&w=2

for now I'll add a small workaround in the source and remove it in ~6 months or so after git releases a fix for their bug

Resolving patch:
diff --git a/pre_commit/commands/autoupdate.py b/pre_commit/commands/autoupdate.py
--- a/pre_commit/commands/autoupdate.py
+++ b/pre_commit/commands/autoupdate.py
@@ -67,6 +67,8 @@ def update(self, tags_only: bool, freeze: bool) -> RevInfo:
                     rev, frozen = exact, rev
 
             try:
+                # workaround for windows -- see #2865
+                cmd_output_b(*_git, 'show', f'{rev}:{C.MANIFEST_FILE}')
                 cmd_output(*_git, 'checkout', rev, '--', C.MANIFEST_FILE)
             except CalledProcessError:
                 pass  # this will be caught by manifest validating code


Test patch: