While running a batch file in Windows XP I have found randomly occurring error message:
The system cannot find the batch label specified name_of_label
Of course label existed. What causes this error?
Actually, you need 2 conditions for this to happen:
See. The system cannot find the batch label specified (by and Batch-as-batch-can!
David A. Gray mentions in the comments seeing (on Windows 10) what Marshal's answer showed in 2014 (presumably on Windows 7 or 8): a script/batch program (.bat
or .cmd
) executed without CALL
would trigger an eol conversion.
I've written hundreds of batch scripts over the last 35 years, and the only time I've ever had an issue with labels not being found was when the file's line breaks got converted from Windows (CR/LF), which works, to Unix (LF), which doesn't.
Feb. 2020, kinar adds in the comments:
Just encountered this issue on a Win7 machine.
Turns out this error can also be generated when trying to CALL another.bat
file if that file doesn't exist on the system.
In my case, I was trying to call the Visual Studiovcvarsall.bat
file on a system without VS installed.
See jeb's answer for more: it was a case of an undefined label.
Note: in a Git repository, I would recommend a .gitattributes
file with the directive:
*.bat text eol=crlf
If you change it afterward, you need, with Git 2.16+ (Q1 2018):
cd /path/to/repo
git add --renormalize .
git commit -m "apply new .gitattributes"
Brogan adds:
The
.gitattributes
file is ignored by GitHub when downloading a file using the “raw” feature.
GitHub will use the.gitattributes
file when pushing, pulling and cloning, but raw files will always be switched to LF regardless of how you originally saved it.
True:
GitHub's "Raw" download is just HTTP-serving the blob as it sits in the repo storage (which Git always normalizes to LF internally). It does not invoke Git's clean/smudge process, so you always get LF, even if you committed CRLF or have a .gitattributes
rule.
If you clone the repo or pull changes, Git will see your .gitattributes
and convert .bat
files to CRLF on disk.
But if you grab the file via the Raw link on gitHub.com, you will always get LF endings: the "missing label" symptom will still occur until you convert to CRLF yourself.