You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[WinError 123] The syntax for filename, directory name, or volume label is incorrect: '' #1219
I try to install pre-commit with the manual from pre-commit.com.
At step 3 I get the following error message on a Windows 10 machine:
[WinError 123] The syntax for filename, directory name, or volume label is incorrect: ''
.pre-commit-config.yaml
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://server/Sandbox/Repo/_git/Repo
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
error information
An unexpected error has occurred: OSError: [WinError 123] Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch: ''
Traceback (most recent call last):
File "c:\user\programme\python\python37-32\lib\site-packages\pre_commit\error_handler.py", line 72, in error_handler
yield
File "c:\user\programme\python\python37-32\lib\site-packages\pre_commit\main.py", line 294, in main
_adjust_args_and_chdir(args)
File "c:\user\programme\python\python37-32\lib\site-packages\pre_commit\main.py", line 125, in _adjust_args_and_chdir
os.chdir(git.get_root())
OSError: [WinError 123] Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch: ''
An unexpected error has occurred: OSError: [WinError 123] Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch: ''
Check the log at C:\Users\user/.cache\pre-commit\pre-commit.log
Log File
version information
pre-commit version: 1.20.0
sys.version:
3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)]
sys.executable: c:\user\programme\python\python37-32\python.exe
os.name: nt
sys.platform: win32
error information
An unexpected error has occurred: OSError: [WinError 123] Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch: ''
Traceback (most recent call last):
File "c:\user\programme\python\python37-32\lib\site-packages\pre_commit\error_handler.py", line 72, in error_handler
yield
File "c:\user\programme\python\python37-32\lib\site-packages\pre_commit\main.py", line 294, in main
_adjust_args_and_chdir(args)
File "c:\user\programme\python\python37-32\lib\site-packages\pre_commit\main.py", line 125, in _adjust_args_and_chdir
os.chdir(git.get_root())
OSError: [WinError 123] Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch: ''
that's very strange! from the trace it looks like the same command being called from python is returning 0 but not printing the git root -- can you try a few more things for me?
@asottile I reinstall git, when I execute pre-commit install inside Repo\.git\hooks (where .pre-commit-config.yaml stored) I still get null as output when I execute git rev-parse --show-toplevel.
If I excute git rev-parse --show-toplevel in Repo it returns C:/Users/user/Desktop/Sandbox/Repo. Does this change something?
The next release (probably v1.20.1 when I have some time to release) will include a better error message for this:
$ pre-commit installAn error has occurred: FatalError: git toplevel unexpectedly empty! make sure you are not inside the `.git` directory of your repository.Check the log at /home/asottile/.cache/pre-commit/pre-commit.log
I'm also seeing if I can fix this from the git side, since the behaviour seems quite strange!
Activity
asottile commentedon Nov 12, 2019
This looks like your
gitis broken, what does the following say:you should get something like
Also could you please include the command you ran, the full unedited output, and the contents of the log file it mentions?
Nusserdt commentedon Nov 13, 2019
Sorry I forget to mention.
Command
Output
Log File
version information
error information
asottile commentedon Nov 13, 2019
that's very strange! from the trace it looks like the same command being called from python is returning 0 but not printing the git root -- can you try a few more things for me?
python -c "from pre_commit.util import cmd_output; print(cmd_output('git', 'rev-parse', '--show-toplevel'))"For me it produces something like:
Nusserdt commentedon Nov 13, 2019
Input
Output
asottile commentedon Nov 13, 2019
How about this one?
python -c "from pre_commit.parse_shebang import find_executable; print(find_executable('git'))"Nusserdt commentedon Nov 14, 2019
Input
Output
(custom path)
asottile commentedon Nov 14, 2019
what happens if you run the
rev-parse --show-toplevelcommand with that executable?Nusserdt commentedon Nov 15, 2019
Input
Output
asottile commentedon Nov 15, 2019
that seems to be the problem then! could you try reinstalling
gitmaybe?Nusserdt commentedon Nov 18, 2019
@asottile I reinstall git, when I execute
pre-commit installinsideRepo\.git\hooks(where.pre-commit-config.yamlstored) I still getnullas output when I executegit rev-parse --show-toplevel.If I excute
git rev-parse --show-toplevelinRepoit returnsC:/Users/user/Desktop/Sandbox/Repo. Does this change something?asottile commentedon Nov 18, 2019
the pre-commit configuration should be inside the root of your repository (also where you'll run
pre-commit installfrom) -- does that change things?oh wow I just tried this,
gitis the wackiest thing!?asottile commentedon Nov 18, 2019
The next release (probably v1.20.1 when I have some time to release) will include a better error message for this:
I'm also seeing if I can fix this from the
gitside, since the behaviour seems quite strange!asottile commentedon Jan 2, 2020
This has been released as part of v1.21.0 (it was also fixed in git 1.24 I believe) -- thanks again for the issue 🎉!