Skip to content

Fix stackql binary resolution in the test harnesses (WSL spawn ENOENT) - #3

Merged
jeffreyaven merged 1 commit into
mainfrom
claude/anthropic-stackql-providers-m8s5mg
Jul 8, 2026
Merged

Fix stackql binary resolution in the test harnesses (WSL spawn ENOENT)#3
jeffreyaven merged 1 commit into
mainfrom
claude/anthropic-stackql-providers-m8s5mg

Conversation

@jeffreyaven

Copy link
Copy Markdown
Contributor

Fixes the npm run test-meta-routes crash on a fresh WSL clone:

Error: spawn stackql ENOENT

Root cause

Two bugs compounding:

  1. The npm script forced STACKQL=${STACKQL:-stackql} — a bare command name. fs.existsSync('stackql') resolves bare names against the CWD (so a stackql file in the repo root passes the check), but spawn('stackql') resolves against PATH — so the exists-check passed and the spawn died.
  2. The harness had no error handler on the spawned child, so the ENOENT surfaced as an unhandled 'error' event and crashed node with a raw stack trace (plus a confusing stopping server (pid undefined) on the way down).

Fix

  • Robust binary resolution in test-meta-routes.cjs (both providers) and tests/smoke.cjs, always resolving to an absolute path before spawn: $STACKQL/--stackql/manifest config (as a path, or PATH-resolved when a bare command) → <provider>/stackql./stackqlstackql on PATH → download the latest release into the provider dir (the same fallback bin/start-server.sh has always had; linux/darwin, amd64/arm64).
  • Spawn error handler → friendly one-line failure instead of an unhandled-event stack trace; suppressed the pid undefined stop log when the spawn never succeeded.
  • npm script: dropped the STACKQL=${STACKQL:-stackql} prefix (also non-portable on Windows cmd); STACKQL remains an optional override.
  • README notes updated (harness auto-downloads; env var optional). Downloaded binaries are covered by the stackql .gitignore entry added on main.

Verification (all resolution paths exercised)

  • STACKQL=stackql with no binary anywhere (the reported case) → warns, downloads, full 12/26/104 meta walk, zero errors
  • admin harness with no binary → self-downloads, 6/11/27 walk, zero errors
  • STACKQL=/abs/path → smoke 13/13
  • no env var, repo-local binary present → admin smoke 20/20

🤖 Generated with Claude Code

https://claude.ai/code/session_01M5qQSBivc7W458yqJG9i5a


Generated by Claude Code

fs.existsSync resolves bare names against the CWD while spawn() resolves
them against PATH, so 'STACKQL=stackql' could pass the exists-check (a
repo-root file) and then crash node with an unhandled spawn ENOENT.

- test-meta-routes.cjs (both providers) + smoke.cjs: resolve the binary
  to an ABSOLUTE path — $STACKQL/--stackql/config (path or PATH-resolved
  command) → <provider>/stackql → ./stackql → 'stackql' on PATH → download
  the latest release into the provider dir (the same fallback
  bin/start-server.sh has always had)
- handle the spawn 'error' event (friendly message instead of a raw
  unhandled-event stack trace); skip the 'stopping server (pid
  undefined)' log when the spawn never succeeded
- package.json: drop the 'STACKQL=${STACKQL:-stackql}' prefix from
  test-meta-routes (non-portable on Windows cmd, and the bare-name
  default defeated the harness's own resolution)

All paths verified: bare unresolvable env var → download → 104-method
walk zero errors; admin harness self-downloads → zero errors; absolute
STACKQL and repo-local binary paths → smoke 13/13 and 20/20.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M5qQSBivc7W458yqJG9i5a
@jeffreyaven
jeffreyaven merged commit b41c6f7 into main Jul 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants