Skip to content

Windows: install.ps1 fails with SyntaxError due to node -e truncating at double-quotes #249

@scottconverse

Description

@scottconverse

Bug

install.ps1 fails on Windows PowerShell 5.1 with a SyntaxError mid-way through the JSON merge script:

[eval]:17
      command: 'node '
                      
Expected ',', got '<eof>'

SyntaxError: Unexpected end of input

Root cause

Line 183 passes the multiline JS here-string to Node via node -e $nodeScript. On Windows, PowerShell passes arguments to external executables through the Windows command processor, which terminates the argument at the first unescaped double-quote character. The JS string contains 'node "' + hooksDir + ... — the " after node ends the argument, so Node only receives a truncated fragment.

The hook files are copied successfully but settings.json is never updated, leaving caveman non-functional.

Fix

Write the script to a temp file and run node tempfile.js instead of node -e. Temp file is cleaned up in a finally block.

$tmpScript = Join-Path $env:TEMP "caveman-install-$([System.Diagnostics.Process]::GetCurrentProcess().Id).js"
try {
    [System.IO.File]::WriteAllText($tmpScript, $nodeScript, [System.Text.Encoding]::UTF8)
    node $tmpScript
} finally {
    if (Test-Path $tmpScript) { Remove-Item $tmpScript -Force }
}

PR with fix: https://github.com/scottconverse/caveman/pull/new/fix/windows-node-e-truncation

Environment

  • Windows 11 Pro 10.0.26200
  • Windows PowerShell 5.1
  • Node.js v24.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions