fix(coding-agent): accept managed install markers with a UTF-8 BOM

Windows PowerShell 5.1 adds a BOM when it rewrites managed-install.json, which made pi update fail with "Managed install marker is missing or invalid".
This commit is contained in:
Armin Ronacher 2026-10-20 10:29:22 +02:00
parent 530015d93a
commit ea25697e91
3 changed files with 21 additions and 1 deletions

View file

@ -37,6 +37,7 @@ import { hasTrustRequiringProjectResources, ProjectTrustStore } from "./core/tru
import { spawnProcess, spawnProcessSync, waitForChildProcess } from "./utils/child-process.ts";
import { canonicalizePath, getCwdRelativePath } from "./utils/paths.ts";
import { getPiUserAgent } from "./utils/pi-user-agent.ts";
import { stripBom } from "./utils/text.ts";
import { formatVersionCheckError, getLatestPiRelease, isNewerPackageVersion } from "./utils/version-check.ts";
import {
cleanupWindowsSelfUpdateQuarantine,
@ -63,7 +64,7 @@ function getActiveManagedInstallRoot(): string | undefined {
const markerPath = join(managedRoot, MANAGED_INSTALL_MARKER);
try {
const marker = JSON.parse(readFileSync(markerPath, "utf8")) as {
const marker = JSON.parse(stripBom(readFileSync(markerPath, "utf8"))) as {
kind?: unknown;
layout?: unknown;
schemaVersion?: unknown;