[GH-ISSUE #570] Windows: every ASAR analysis fails with artifact_operation_failed (platform path separators not handled in AsarArtifactReader) #295

Closed
opened 2026-10-15 18:23:34 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @rishiteja21 on GitHub (Oct 5, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/570

Environment

  • rea-agents 3.2.1 (npm)
  • Node.js v24.20.0, Windows 11 x64 (build 26300)
  • @electron/asar 4.2.0

Summary

On Windows, analyze_javascript_application (and rea analyze) fails for every .asar with:

{
  "code": "artifact_operation_failed",
  "category": "execution_failure",
  "message": "Artifact is invalid or has changed. Get a fresh copy and try again.",
  "details": { "operation": "analyze_javascript_application", "reason": "format" }
}

The archive is valid — npx @electron/asar list app.asar enumerates all entries fine. No valid ASAR can be analyzed on Windows.

Root cause

AsarArtifactReader.entries() (src/artifacts/AsarArtifactReader.ts):

  1. listPackage (line 30) returns entry paths using the platform separator, with a leading separator — on Windows: \node_modules, \node_modules\@formatjs, …
  2. Line 34 strips only forward slashes:
    const path = listed.replace(/^\/+|\/+$/gu, "");
    
    so on Windows the leading \ survives (\node_modules).
  3. Line 38 passes that key to statFile(this.path, path, false). @electron/asar's Filesystem.getFile splits lookup keys on path.sep (\ on Windows), so the key \node_modules resolves to an empty first component and fails with '"\node_modules" was not found in this archive'. asarFailure wraps this into a format failure, which surfaces as the generic artifact_operation_failed above.
  4. adapterKey (line 69) keeps the same malformed key, so extractFile would fail the same way.

On macOS/Linux listPackage emits /node_modules/..., the regex strips the leading /, and lookups succeed — hence Windows-only.

Fix

Normalize separators and use path.sep for @electron/asar lookups while keeping graph-facing paths POSIX. The following patch (applied to the installed dist) was verified: rea analyze on a real 118 MB Electron app.asar proceeds past inventory and completes:

import { sep } from "node:path";

const path = listed.replace(/^[\/]+|[\/]+$/gu, "").replace(/\/gu, "/");
...
metadata = statFile(this.path, path.split("/").join(sep), false);
...
adapterKey: path.split("/").join(sep),

rea doctor --json fails on Windows with spawn EINVAL: RuntimeExecutableDiagnostics discovers .CMD/.BAT candidates (npm.cmd, npx.cmd) on PATH and spawns them without shell, which Node.js (≥20.12) rejects with EINVAL. Diagnostics-only, but it hides the capability matrix on Windows.

Originally created by @rishiteja21 on GitHub (Oct 5, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/570 ### Environment - `rea-agents` 3.2.1 (npm) - Node.js v24.20.0, Windows 11 x64 (build 26300) - `@electron/asar` 4.2.0 ### Summary On Windows, `analyze_javascript_application` (and `rea analyze`) fails for **every** `.asar` with: ```json { "code": "artifact_operation_failed", "category": "execution_failure", "message": "Artifact is invalid or has changed. Get a fresh copy and try again.", "details": { "operation": "analyze_javascript_application", "reason": "format" } } ``` The archive is valid — `npx @electron/asar list app.asar` enumerates all entries fine. No valid ASAR can be analyzed on Windows. ### Root cause `AsarArtifactReader.entries()` (`src/artifacts/AsarArtifactReader.ts`): 1. `listPackage` (line 30) returns entry paths using the **platform** separator, with a leading separator — on Windows: `\node_modules`, `\node_modules\@formatjs`, … 2. Line 34 strips only forward slashes: ```ts const path = listed.replace(/^\/+|\/+$/gu, ""); ``` so on Windows the leading `\` survives (`\node_modules`). 3. Line 38 passes that key to `statFile(this.path, path, false)`. `@electron/asar`'s `Filesystem.getFile` splits lookup keys on `path.sep` (`\` on Windows), so the key `\node_modules` resolves to an empty first component and fails with `'"\node_modules" was not found in this archive'`. `asarFailure` wraps this into a `format` failure, which surfaces as the generic `artifact_operation_failed` above. 4. `adapterKey` (line 69) keeps the same malformed key, so `extractFile` would fail the same way. On macOS/Linux `listPackage` emits `/node_modules/...`, the regex strips the leading `/`, and lookups succeed — hence Windows-only. ### Fix Normalize separators and use `path.sep` for `@electron/asar` lookups while keeping graph-facing paths POSIX. The following patch (applied to the installed `dist`) was verified: `rea analyze` on a real 118 MB Electron `app.asar` proceeds past inventory and completes: ```ts import { sep } from "node:path"; const path = listed.replace(/^[\/]+|[\/]+$/gu, "").replace(/\/gu, "/"); ... metadata = statFile(this.path, path.split("/").join(sep), false); ... adapterKey: path.split("/").join(sep), ``` ### Related observation (separate cause, also blocks Windows use) `rea doctor --json` fails on Windows with `spawn EINVAL`: `RuntimeExecutableDiagnostics` discovers `.CMD`/`.BAT` candidates (`npm.cmd`, `npx.cmd`) on PATH and spawns them without `shell`, which Node.js (≥20.12) rejects with `EINVAL`. Diagnostics-only, but it hides the capability matrix on Windows.
bsakaguchi 2026-10-15 18:23:34 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#295
No description provided.