Skip to content

install.bat: fix parens-in-username breaking OTP path expansion#1826

Open
hanuele wants to merge 1 commit into
elixir-lang:mainfrom
hanuele:fix/install-bat-parens-in-username
Open

install.bat: fix parens-in-username breaking OTP path expansion#1826
hanuele wants to merge 1 commit into
elixir-lang:mainfrom
hanuele:fix/install-bat-parens-in-username

Conversation

@hanuele
Copy link
Copy Markdown

@hanuele hanuele commented May 20, 2026

Summary

On Windows, when %USERPROFILE% contains parentheses (e.g. C:\Users\PeterLinder(3Txpert)), install.bat fails on the OTP download/unpack step with a German "syntactisch nicht verarbeitbar" / English "... was unexpected at this time" cmd-batch parse error — before any download begins.

Root cause: four lines in install.bat use unquoted %tmp_dir% inside if (...) blocks. Because cmd-batch performs %var% expansion at parse time (not execution time), the close-paren embedded in %tmp_dir% terminates the surrounding if block prematurely. The cmd parser then sees a then-clause without an opening paren.

This PR applies two patterns already present elsewhere in the file:

  • Quote the path argument at the curl.exe (line 148) and del /f /q (line 205) calls. The Elixir-side curl at line 192 was already correctly quoted — this restores symmetry with the OTP-side calls.
  • Use delayed expansion (!tmp_dir!\!otp_zip!) at the two echo unpacking … lines (150, 194). Delayed expansion happens at execution time, after the parser has already matched the if-block parens.

The change is minimal (4 lines) and entirely additive: every modified line was either missing quotes or using the wrong expansion form; no existing behavior changes for usernames without parentheses.

Reproduction

On a Windows account with ( in the username:

.\install.bat elixir@latest otp@latest

Before patch: errors at the OTP curl/echo step before the download starts.

After patch: both downloads complete cleanly; OTP and Elixir install as expected.

Test plan

  • Manual: install.bat elixir@latest otp@latest runs cleanly under PeterLinder(3Txpert) (parenthesized) — both OTP and Elixir downloaded, unpacked, and version-checked.
  • Manual: same command continues to work under a non-parenthesized username (no regression).
  • Diff against main: 4 lines changed, no other changes.

🤖 Generated with Claude Code

On Windows, when %USERPROFILE% contains parentheses (e.g.
`PeterLinder(3Txpert)`), four lines in install.bat fail because
%tmp_dir% expands inside `if (...)` cmd-batch blocks at parse time —
the embedded close-paren terminates the if-block early, producing
"syntactisch nicht verarbeitbar" / "syntactically unprocessable"
errors before the OTP download even begins.

Two complementary fixes match the existing patterns:

- Quote the path argument in curl.exe / del (lines 148, 205) — the
  Elixir-side curl at line 192 was already correctly quoted; this
  restores symmetry with the OTP-side calls.
- Use delayed expansion `!tmp_dir!\!otp_zip!` (lines 150, 194) — both
  are inside if-blocks where %tmp_dir% would expand at parse time.
  Delayed expansion expands at execution time, after the parser has
  already matched the if-block parens.

Verified locally on a Windows account with parenthesized username:
unpatched `install.bat elixir@latest otp@latest` fails before OTP
download; patched version completes both downloads cleanly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant