fix(install): batch parse error aborted install.bat at OCR stage

Live clean-install test caught a syntax bug in the new Tesseract setup
block: install.bat died with "so was unexpected at this time." right
after "Setting up OCR...", so OCR setup and the whole dependency
verification stage never ran.

Cause: "::" comment lines placed INSIDE parenthesised if-blocks. Two
problems compound there -- a "::" line inside a ( ) block is itself a
parse error, and any parenthesis in the comment text closes the block
early. The text "(non-zero when already installed), so after each" left
"so" as a stray token.

Fix: move every comment out of the parenthesised blocks, in both the
Tesseract block and the conda winget block added earlier. The conda one
had survived only because its text happened to contain no parentheses.

Verified: install.bat now runs to completion with exit 0 --
  Tesseract: C:\Program Files\Tesseract-OCR\tesseract.exe
  pytesseract: OK (tesserocr: DLL issue, expected)
  cv2/mss/numpy/transitions/rapidfuzz/pydantic/pytesseract/yaml/discord: OK
  All dependencies verified.
140 tests pass against the freshly created env.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
alexpolo1
2026-08-05 21:38:23 +02:00
co-authored by Claude Opus 4.8
parent 61a88d2968
commit 710c1c709a
+14 -9
View File
@@ -64,14 +64,15 @@ echo.
:: (no elevation) then fails silently and conda never installs. --scope user
:: installs to %USERPROFILE%\miniforge3 with no admin needed — which is also one
:: of the locations :rescan_conda searches.
:: winget returns non-zero when the package is already installed, so don't
:: trust the exit code -- rescan for conda and only fall through to the direct
:: download if it's genuinely still missing. Keep this comment outside the block:
:: a "::" line inside a ( ) block is a parse error.
winget --version >nul 2>&1
if %errorlevel% equ 0 (
echo Installing via winget...
winget install --id CondaForge.Miniforge3 --exact --silent --scope user ^
--accept-package-agreements --accept-source-agreements
:: winget returns non-zero when the package is already installed, so don't
:: trust the exit code — rescan for conda and only fall through to the
:: direct download if it's genuinely still missing.
for %%C in (
"%LOCALAPPDATA%\miniforge3\Scripts\conda.exe"
"%USERPROFILE%\miniforge3\Scripts\conda.exe"
@@ -326,12 +327,16 @@ if %errorlevel% neq 0 (
echo WARNING: Could not install pytesseract Python wrapper.
)
:: Try winget machine scope, then user scope -- the latter needs no admin.
:: winget's exit code is unreliable, being non-zero when the package is already
:: installed, so after each attempt we re-resolve tesseract.exe instead of
:: trusting errorlevel.
:: NOTE: comments must stay OUTSIDE the parenthesised blocks below. A "::" line
:: inside a ( ) block is a parse error, and any parenthesis in the comment text
:: closes the block early.
call :find_tesseract
if not defined TESS_EXE (
echo Installing Tesseract OCR...
:: Try winget machine scope, then user scope (no admin needed). winget's
:: exit code is unreliable (non-zero when already installed), so after each
:: attempt we re-resolve tesseract.exe rather than trusting errorlevel.
winget --version >nul 2>&1
if !errorlevel! equ 0 (
winget install --id tesseract-ocr.tesseract --exact --silent ^
@@ -347,6 +352,9 @@ if not defined TESS_EXE (
:: Last resort: direct download of the official NSIS installer and a per-user
:: install. Covers clean Win10 machines with no winget and no admin rights.
:: The size check guards against a truncated download or an HTML error page;
:: the installer is ~50 MB. NSIS /D= must come last and unquoted, and breaks on
:: paths containing spaces, so it is only used when the target path has none.
if not defined TESS_EXE (
echo winget unavailable or failed -- downloading Tesseract directly...
set "TS_INSTALLER=%TEMP%\tesseract-setup.exe"
@@ -358,12 +366,9 @@ if not defined TESS_EXE (
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$ProgressPreference='SilentlyContinue'; try { Invoke-WebRequest -Uri '!TS_URL!' -OutFile '!TS_INSTALLER!' -UseBasicParsing; exit 0 } catch { exit 1 }"
)
:: Sanity-check the size (installer is ~50 MB) before executing it.
set "TS_SIZE=0"
if exist "!TS_INSTALLER!" for %%A in ("!TS_INSTALLER!") do set "TS_SIZE=%%~zA"
if !TS_SIZE! GEQ 20971520 (
:: NSIS /D= must be last and unquoted, and breaks on paths containing
:: spaces -- so only use it when the target path has none.
echo !TS_DEST! | find " " >nul
if !errorlevel! equ 0 (
start /wait "" "!TS_INSTALLER!" /S