Skip to content

fix(windows): make installer PowerShell-compatible - #2621

Open
jeeaay wants to merge 1 commit into
MemTensor:mainfrom
jeeaay:fix/windows-installer-compat
Open

jeeaay wants to merge 1 commit into
MemTensor:mainfrom
jeeaay:fix/windows-installer-compat

Conversation

@jeeaay

@jeeaay jeeaay commented Nov 16, 2026

Copy link
Copy Markdown

Summary

Fix Windows installer failures observed with the supported PowerShell installer on a Git/MSYS-enabled Windows environment.

Problems fixed

  • Avoid nested JavaScript quote loss when PowerShell invokes the Node native command for the Node >=22 check.
  • Use the native Windows System32\tar.exe instead of PATH-dependent Git/MSYS tar, which interprets C:\... paths incorrectly.
  • Write .memos-node-bin as UTF-8 without a BOM. Windows PowerShell Set-Content -Encoding UTF8 writes a BOM, causing the Hermes adapter to reject the recorded Node path and silently fall back to a potentially incompatible Node runtime.

Verification

  • PowerShell AST parse passed.
  • Node v25.2.1 version-check expression passed.
  • git diff --check passed.
  • The patched installer was executed successfully on Windows: package 2.0.21 downloaded, dependencies installed, existing config preserved, and the Memory Viewer started at http://127.0.0.1:18800/.

Scope

This changes only apps/memos-local-plugin/install.ps1; no runtime data or user configuration is modified.

@Memtensor-AI Memtensor-AI added area:plugin OpenClaw & Hermes status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Nov 16, 2026
@Memtensor-AI

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2621
Task: 3267c7d7431d053f
Base: main
Head: fix/windows-installer-compat
Head SHA: 32da65e53d60b7baf52ae772cafbf1b912fd3ede

🔍 OpenCodeReview found 2 issue(s) in this PR.


1. apps/memos-local-plugin/install.ps1 (L392-L393)

Writing the marker as UTF-8 without a BOM fixes the Python consumers (bridge_client.py/daemon_manager.py call read_text(encoding="utf-8").strip(), which kept the BOM and made the path unusable), but it silently breaks the in-script consumer: line 846 reads this file with plain Get-Content under Windows PowerShell 5.1, where a BOM-less file is decoded using the ANSI code page. For non-ASCII node paths (e.g. nvm-windows under C:\Users\<non-ASCII user>\..., or a localized ProgramFiles), $NodeBin becomes mojibake, the -not $NodeBin fallback is not taken because the string is non-empty, and the daemon start at line 859/862 fails with a confusing "file not found" error. Please make the reader encoding-explicit when changing the writer.

💡 Suggested Change

Before:

        $NodeMarkerPath = Join-Path $StagedPrefix ".memos-node-bin"
        [IO.File]::WriteAllText($NodeMarkerPath, "$NodeForBridge`n", (New-Object System.Text.UTF8Encoding $false))

After:

        $NodeMarkerPath = Join-Path $StagedPrefix ".memos-node-bin"
        [IO.File]::WriteAllText($NodeMarkerPath, "$NodeForBridge`n", (New-Object System.Text.UTF8Encoding $false))
        # NOTE: consumers must read this as UTF-8 explicitly (e.g.
        # Get-Content -Encoding UTF8 / [IO.File]::ReadAllText) because it has no BOM.

2. apps/memos-local-plugin/install.ps1 (L360-L361)

Pinning extraction to %SystemRoot%\System32\tar.exe removes the previous PATH-based tar resolution, so hosts without the OS-bundled bsdtar (Windows 10 < 1803, Server 2016, and 32-bit shells where System32 is redirected to SysWOW64) now hard-fail with "Windows tar.exe not found" even when a usable tar is present. Also, if $env:SystemRoot is empty in the current environment, Join-Path throws a parameter-binding error instead of the intended message. Consider validating $env:SystemRoot first and keeping a constrained fallback to Get-Command tar.

💡 Suggested Change

Before:

        $WindowsTar = Join-Path $env:SystemRoot "System32\tar.exe"
        if (-not (Test-Path $WindowsTar)) { throw "Windows tar.exe not found" }

After:

        if (-not $env:SystemRoot) { throw "Windows tar.exe not found: SystemRoot is not set" }
        $WindowsTar = Join-Path $env:SystemRoot "System32\tar.exe"
        if (-not (Test-Path $WindowsTar)) {
            $WindowsTar = (Get-Command "tar" -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1).Source
        }
        if (-not $WindowsTar) { throw "Windows tar.exe not found" }

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:plugin OpenClaw & Hermes status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants