cli-rs: check:drift fails to spawn Git on Windows when deriving its working directory from a file URL
Upstream dev @ e1d864a24d, Windows 10 x64 (build 19045), Bun 1.4.4. Commands below use PowerShell.
From a drive-letter checkout with dependencies installed:
cd packages/cli-rs
git rev-parse --show-toplevel
bun run check:drift
Git prints the repository root. The drift check exits 1 at the first snapshot with "ENOENT: no such file or directory, uv_spawn 'git'". It never reaches the first generator.
script/drift.ts passes new URL("..", import.meta.url).pathname to Bun.spawnSync as cwd. A Windows file URL yields /E:/... and preserves percent escapes. A native filesystem path is expected there. Several generators also derive their paths the same way, so fixing just the initial spawn would leave the same issue downstream.
Source: https://github.com/anomalyco/opencode/blob/e1d864a24dec1507160e430597eae53487358c21/packages/cli-rs/script/drift.ts#L13
Thanks for the precise report. I couldn't run Windows here, but I reproduced the same failure on Linux at e1d864a24, which is still the latest dev.
drift.ts line 12 builds its working directory with new URL("..", import.meta.url).pathname. That value keeps percent escapes on every platform, so a checkout whose path contains a space fails the same way. The first git spawn in the snapshot step fails with ENOENT: no such file or directory, posix_spawn 'git' and the script exits 1. The same checkout in a path without a space gets past the snapshot and starts running the generators. The script below runs both cases.
I didn't run the Windows drive-letter case (/E:/...) myself, but it comes from the same line. As you noted, perf.ts and most of the scripts in script/gen/ build their paths the same way, so a fix should cover all of them.
Reproduction script (repro.sh)
#!/bin/sh
# Reproduces #67080's percent-escape half on Linux: check:drift derives its cwd from
# new URL("..", import.meta.url).pathname, which keeps "%20" for a space, so the first
# git spawn fails with ENOENT. A control checkout without a space gets past it.
# Usage: repro.sh [source repo] [commit] (defaults: GitHub, dev)
SRC=${1:-https://github.com/anomalyco/opencode.git}
REV=${2:-dev}
BASE=$(mktemp -d)
for dir in "with space" nospace; do
mkdir -p "$BASE/$dir"
git clone -q --no-checkout "$SRC" "$BASE/$dir/r"
cd "$BASE/$dir/r" && git sparse-checkout set packages/cli-rs/script >/dev/null 2>&1 && git checkout -q "$REV"
echo "=== $BASE/$dir/r ($(git rev-parse --short HEAD))"
cd packages/cli-rs && timeout 20 bun run script/drift.ts 2>&1 | grep -E "ENOENT|drift: bun run" | head -2
done
Run it: sh repro.sh