Skip to content

Fix: health_check.bat no longer splits a Windows install path that co…#18178

Open
wallner-avat wants to merge 1 commit into
apache:masterfrom
wallner-avat:patch-1
Open

Fix: health_check.bat no longer splits a Windows install path that co…#18178
wallner-avat wants to merge 1 commit into
apache:masterfrom
wallner-avat:patch-1

Conversation

@wallner-avat

Copy link
Copy Markdown

…ntains a space

Fixes #18177

Description

Symptom

On Windows, when IoTDB is located under a path that contains a space (e.g. C:\Program Files\iotdb), the health-check tool's Installation Environment(Directory Access) check splits directory paths at the space. It:

  • creates a stray empty directory such as C:\Program, and
  • prints garbled results — "C:\Program" has write permission followed by "Files\...\ext\pipe" has write permission — instead of one line for the real directory.

Reproduced on 2.0.8 and current master (identical code). Present since the tool was added (#12325); not addressed by #12435 (launch scripts) or #12450 (permission-detection logic).

Root cause

In scripts/tools/windows/ops/health_check.bat, :local_dirs_check joins the directory variables into spacedirs with spaces and iterates them with for %%a in (%spacedirs%). The for ... in (set) form tokenizes on spaces (and
,/;), so a path containing a space is split into two tokens. The inner for %%b/%%c loops already preserve spaces for the ;/, multi-dir separators (via the "!var:;=" "!" technique), but the outer space-join defeats that.
Separately, %%c (from for %%c in ("...")) carries its surrounding quotes, so mkdir "%%c" expands to mkdir ""C:\Program Files\..."" — a doubly-quoted path the argument parser re-splits, recreating the stray directory even after the
outer loop is fixed.

Fix

Two coordinated changes in :local_dirs_check, both required:

  1. Build the directory list with each entry individually quoted and de-quote it with %%~a, so the outer loop yields exactly one entry per configured variable with spaces intact.
  2. Use the de-quoted %%~c for every filesystem operation and result message (mkdir, if not exist, and the temp-file write/exist/delete), so they receive a single correctly-quoted path. The for %%c in (...) loop variable itself is
    unchanged.

A short @REM in :local_dirs_check documents why the list is quoted.

Behavior:

  • Space-free installs are unchanged.
  • Existing ;/,-separated multi-directory values still split correctly.
  • A spaced path is now checked as a single directory; no stray directory is created; the output has one clean line per directory.

Alternatives considered:

  • Rewriting the loop with for /f and explicit ,/; delimiters — a larger change with no functional advantage; the quote-preserving approach is minimal and reuses the technique already present in the inner loops.
  • Relying on the "no spaces in the install path" documentation alone — the docs do recommend a space-free path, but the tool should still degrade gracefully (not create stray directories or emit corrupt output) when that guidance isn't met,
    which is common on Windows where C:\Program Files is the natural location.

Testing

No automated harness exists for the batch tool, so verified manually on Windows:

  • Install under C:\Program Files\iotdb, run health_check.bat -o local: before → stray empty C:\Program created + split/garbled Directory Access lines; after → no stray directory, one clean line per directory (e.g. C:\Program Files\iotdb\ext\pipe has write permission).
  • Space-free install: output unchanged.
  • Config with a ;/,-separated dn_data_dirs: still enumerated correctly.

This PR has:

  • been self-reviewed.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.

Key changed/added classes (or packages if there are too many classes) in this PR
  • scripts/tools/windows/ops/health_check.bat:local_dirs_check routine (Windows batch script; no Java classes changed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] health_check.bat creates a stray empty directory (e.g. C:\Program) when the install path contains a space

1 participant