fix(build): make bundle-a2ui.sh work on Windows with WSL#26070
fix(build): make bundle-a2ui.sh work on Windows with WSL#26070BinHPdev wants to merge 2 commits intoopenclaw:mainfrom
Conversation
On Windows, pnpm resolves 'bash' to WSL (System32/bash.exe) rather than Git Bash. WSL typically has no native Node.js, so every node-dependent call in bundle-a2ui.sh fails (compute_hash inline script, pnpm-wrapped tsc/rolldown). Two fixes: 1. Replace the Node.js inline script in compute_hash with a pure-bash sha256sum/_sha256 implementation. sha256sum is available natively in WSL, Git Bash (Git for Windows), and Linux; shasum -a 256 covers macOS. This removes the node dependency from hash computation entirely. 2. Detect WSL via /proc/version and exit early using the prebuilt bundle when present, mirroring the existing Docker fallback pattern. If no prebuilt bundle exists in WSL, print a clear actionable error guiding the developer to run the script outside WSL (Git Bash or cmd). Fixes openclaw#26065
The inner function named its parameter 'params', shadowing the outer
runEmbeddedPiAgent 'params: RunEmbeddedPiAgentParams'. The function body
then accessed 'params.config' and 'params.agentDir', which don't exist
on the inner type and caused TS2339 errors during build:plugin-sdk:dts.
Rename the inner parameter to 'failureParams' so the function body
correctly reads 'params.config' (outer RunEmbeddedPiAgentParams.config)
and 'agentDir' (the local variable resolved at line 230), matching the
signature of markAuthProfileFailure({ cfg, agentDir }).
| ( | ||
| for input_path in "${INPUT_PATHS[@]}"; do | ||
| if [[ -d "$input_path" ]]; then | ||
| while IFS= read -r -d '' f; do | ||
| printf '%s\0' "${f#"$ROOT_DIR/"}" | ||
| _sha256 < "$f" | cut -d' ' -f1 | ||
| printf '\0' | ||
| done < <(find "$input_path" -type f -print0 2>/dev/null | sort -z) | ||
| elif [[ -f "$input_path" ]]; then | ||
| printf '%s\0' "${input_path#"$ROOT_DIR/"}" | ||
| _sha256 < "$input_path" | cut -d' ' -f1 | ||
| printf '\0' | ||
| fi | ||
| done | ||
| ) | _sha256 | cut -d' ' -f1 |
There was a problem hiding this comment.
Hash algorithm changed: old version hashed raw file contents, new version hashes the SHA256 of each file then hashes those hashes together. This breaks cache compatibility—any existing .bundle.hash will never match, forcing a rebuild on first run after this change.
| ( | |
| for input_path in "${INPUT_PATHS[@]}"; do | |
| if [[ -d "$input_path" ]]; then | |
| while IFS= read -r -d '' f; do | |
| printf '%s\0' "${f#"$ROOT_DIR/"}" | |
| _sha256 < "$f" | cut -d' ' -f1 | |
| printf '\0' | |
| done < <(find "$input_path" -type f -print0 2>/dev/null | sort -z) | |
| elif [[ -f "$input_path" ]]; then | |
| printf '%s\0' "${input_path#"$ROOT_DIR/"}" | |
| _sha256 < "$input_path" | cut -d' ' -f1 | |
| printf '\0' | |
| fi | |
| done | |
| ) | _sha256 | cut -d' ' -f1 | |
| compute_hash() { | |
| # Pure-bash hash using _sha256 — avoids Node.js, which is absent in WSL | |
| # when bash is invoked from Windows (pnpm uses WSL bash via System32/bash.exe). | |
| # Hashes sorted relative paths + file contents for stable cache detection. | |
| ( | |
| for input_path in "${INPUT_PATHS[@]}"; do | |
| if [[ -d "$input_path" ]]; then | |
| while IFS= read -r -d '' f; do | |
| printf '%s\0' "${f#"$ROOT_DIR/"}" | |
| cat "$f" | |
| printf '\0' | |
| done < <(find "$input_path" -type f -print0 2>/dev/null | sort -z) | |
| elif [[ -f "$input_path" ]]; then | |
| printf '%s\0' "${input_path#"$ROOT_DIR/"}" | |
| cat "$input_path" | |
| printf '\0' | |
| fi | |
| done | |
| ) | _sha256 | cut -d' ' -f1 | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/bundle-a2ui.sh
Line: 62-76
Comment:
Hash algorithm changed: old version hashed raw file contents, new version hashes the SHA256 of each file then hashes those hashes together. This breaks cache compatibility—any existing `.bundle.hash` will never match, forcing a rebuild on first run after this change.
```suggestion
compute_hash() {
# Pure-bash hash using _sha256 — avoids Node.js, which is absent in WSL
# when bash is invoked from Windows (pnpm uses WSL bash via System32/bash.exe).
# Hashes sorted relative paths + file contents for stable cache detection.
(
for input_path in "${INPUT_PATHS[@]}"; do
if [[ -d "$input_path" ]]; then
while IFS= read -r -d '' f; do
printf '%s\0' "${f#"$ROOT_DIR/"}"
cat "$f"
printf '\0'
done < <(find "$input_path" -type f -print0 2>/dev/null | sort -z)
elif [[ -f "$input_path" ]]; then
printf '%s\0' "${input_path#"$ROOT_DIR/"}"
cat "$input_path"
printf '\0'
fi
done
) | _sha256 | cut -d' ' -f1
}
```
How can I resolve this? If you propose a fix, please make it concise.|
I finally choose to run the whole openclaw to WSL. |
|
Not merged because branch is currently conflicting against main ( This is not doc-only and contains a real runtime fix ( |
|
Thanks for the review @Takhoffman — good call on splitting this up. TypeScript shadow fix: already landed on WSL detection: reopened as a clean, minimal PR from current Closing this PR in favor of #33321. |
Summary
compute_hashwith a portable pure-bashsha256sumimplementation, removing the node dependency from hash computationtsc/rolldowncalls that also require nodemaybeMarkAuthProfileFailurethat causedTS2339errors duringbuild:plugin-sdk:dtsCloses #26065
Root cause
On Windows,
pnpm canvas:a2ui:bundleexecutesbash scripts/bundle-a2ui.sh. Windows resolvesbashtoC:\Windows\System32\bash.exe(WSL), not Git Bash. WSL typically has no native Node.js installed, so two failure points arise:compute_hashcallsnode --input-type=moduleinline →node: command not foundpnpm -s exec tscandpnpm -s dlx rolldowninvoke pnpm's own shell wrapper which also doesexec nodeinternally → same failureA third unrelated failure also blocked the full build:
maybeMarkAuthProfileFailurenamed its inner parameterparams, shadowingRunEmbeddedPiAgentParams params. The body then accessedparams.config/params.agentDirwhich don't exist on the inner type, causingTS2339duringbuild:plugin-sdk:dts.Test plan
pnpm buildcompletes without error on Windows 11 with WSL2 installed (WSL bash invoked by pnpm detects WSL, uses prebuilt bundle, exits 0)pnpm canvas:a2ui:bundlecompletes in Git Bash / macOS / Linux (normal hash + build path viasha256sum)pnpm canvas:a2ui:bundletwice in Git Bash skips the second build with "A2UI bundle up to date; skipping."pnpm buildpasses TypeScript check (build:plugin-sdk:dtsstep) with noTS2339errors🤖 Generated with Claude Code
Greptile Summary
Fixed two distinct issues: (1) WSL compatibility for
bundle-a2ui.shby adding early-exit for WSL environments and replacing Node.js hash computation with bash-native SHA256, and (2) TypeScript parameter shadowing inmaybeMarkAuthProfileFailurethat causedTS2339errors.Major changes:
sha256sum/shasumimplementationparamstofailureParamsand corrected closure variable access (agentDir)Issues found:
Confidence Score: 3/5
scripts/bundle-a2ui.shhash implementation if preserving existing cache files is importantLast reviewed commit: d565656