Pre-commit install fails on Windows network mount drive
See original GitHub issueHi, I’m trying to help some team members set up pre-commit on a Windows network mount drive, and they’re encountering an issue with paths. Seems related to this comment in #1610, which seems to be a different issue than the one the original issue, as we are on the most recent version of pre-commit and git, and the fix that was merged in #1727 for that doesn’t seem to address this issue. I also tried other versions of Git for Windows <2.25, and the issue still seemed to persist.
I tested the solution that @christopherdoyle proposed, and that does seems to fix this issue with network mount drives, though I saw that @asottile would prefer not to use pathlib
. I am not able to propose a fix right now, but I wanted to raise this as an issue that still exists.
Full error below:
### version information
```
pre-commit version: 2.10.1
sys.version:
3.9.1 | packaged by conda-forge | (default, Jan 26 2021, 01:29:07) [MSC v.1916 64 bit (AMD64)]
sys.executable: C:\Users\roderick\.conda\envs\nmt\python.exe
os.name: nt
sys.platform: win32
```
### error information
```
An unexpected error has occurred: ValueError: path is on mount 'S:', start on mount '\\\\MyServer\Directory'
```
```
Traceback (most recent call last):
File "C:\Users\roderick\.conda\envs\nmt\lib\site-packages\pre_commit\error_handler.py", line 65, in error_handler
yield
File "C:\Users\roderick\.conda\envs\nmt\lib\site-packages\pre_commit\main.py", line 333, in main
_adjust_args_and_chdir(args)
File "C:\Users\roderick\.conda\envs\nmt\lib\site-packages\pre_commit\main.py", line 153, in _adjust_args_and_chdir
args.config = os.path.relpath(args.config)
File "C:\Users\roderick\.conda\envs\nmt\lib\ntpath.py", line 703, in relpath
raise ValueError("path is on mount %r, start on mount %r" % (
ValueError: path is on mount 'S:', start on mount '\\\\MyServer\Directory'
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (4 by maintainers)
Top GitHub Comments
From the docs (https://docs.python.org/3/library/os.path.html#os.path.realpath):
Yep, also works for me. Thanks for the quick fix!