Skip to content

PS1 scripts fail to parse on Windows (missing UTF-8 BOM) #590

Description

@augusmendoza

Summary
databricks-mcp-server/mcp_install.ps1 and setup.ps1 fail to parse on Windows with a cascade of unrelated-looking syntax errors (unexpected token, missing closing brace, reserved operator <), even though the code itself is valid. Reproduced on both Windows PowerShell 5.1 and PowerShell 7.6.4.

Root cause
Both files are UTF-8 without a BOM, and contain Unicode decoration characters (✓, ✗, ─). Without a BOM, PowerShell's script encoding detection falls back to the system codepage on Windows and misdecodes the multi-byte sequences. One garbled byte sequence produces a stray quote-like character, which desyncs string parsing for the rest of the file.

Confirmed via [System.Management.Automation.Language.Parser]::ParseFile():

mcp_install.ps1: 15 parse errors, first at line 116 (Write-Host "✓" ...)
setup.ps1: 3 parse errors, same cause

Repro

git clone https://github.com/databricks-solutions/ai-dev-kit.git
cd ai-dev-kit
.\databricks-mcp-server\mcp_install.ps1 -Profile <any-profile> -Tools claude

Fails to parse immediately on a stock Windows machine, both shells.

Fix verified locally
Re-saving each file with a UTF-8 BOM resolves all errors with a content-identical diff (only the leading bytes change):

$content = Get-Content -Raw -Encoding UTF8 $path
Set-Content -Path $path -Value $content -Encoding UTF8 -NoNewline

Suggested fix
Save these .ps1 files with a UTF-8 BOM, or replace the Unicode characters with plain ASCII to remove the encoding dependency entirely (more robust than the workaround above).

Environment
OS: Windows 11 Pro
Shells: Windows PowerShell 5.1.26100.8894, PowerShell 7.6.4
Repo commit: 2d83988 (tag v0.2.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions