Skip to content

fix(jtag): resolve symlinks before deriving SCRIPT_DIR (Carl-Windows chat-probe blocker)#1028

Merged
joelteply merged 1 commit intocanaryfrom
fix/jtag-resolve-symlink-script-dir
May 3, 2026
Merged

fix(jtag): resolve symlinks before deriving SCRIPT_DIR (Carl-Windows chat-probe blocker)#1028
joelteply merged 1 commit intocanaryfrom
fix/jtag-resolve-symlink-script-dir

Conversation

@joelteply
Copy link
Copy Markdown
Contributor

Summary

Fixes the chat-probe failure on Carl-Windows install path uncovered by carl-install-smoke run on Windows/bigmama-1 today.

src/jtag derived SCRIPT_DIR from BASH_SOURCE without resolving symlinks. install.sh 's mod_jtag_bin_link symlinks ~/.local/bin/jtag → src/jtag, so when Carl runs jtag command from PATH, BASH_SOURCE[0] is the symlink path. dirname gives ~/.local/bin — not the directory holding cli-bundle.js or cli.ts.

Result: bundle check silently misses, tsx fallback fires npx tsx ~/.local/bin/cli.ts → ERR_MODULE_NOT_FOUND → chat probe fails with exit 1, the entire chat-probe phase of the install fails.

Fix

readlink -f walks the symlink chain to the real src/jtag, so SCRIPT_DIR resolves to the actual src/ directory regardless of how the user invoked the script. Bundle check and tsx fallback now both work whether jtag was run directly (./jtag from a checkout) or via the symlinked PATH entry (jtag from anywhere).

Why #93 (36e85d2) didn't cover this

#93 changed the tsx fallback from npx tsx cli.ts (cwd-relative) to npx tsx $SCRIPT_DIR/cli.ts (absolute via SCRIPT_DIR). That fixed the direct-./jtag case but left SCRIPT_DIR derivation symlink-unaware, so the much more common symlinked-from-PATH case still resolved to the wrong dir.

Test plan

  • bash -n src/jtag passes
  • CI green (TS compile + tests)
  • Manual: ln -sf /path/to/repo/src/jtag /tmp/jtag-symlink, then /tmp/jtag-symlink --version (should not ERR_MODULE_NOT_FOUND)
  • carl-install-smoke chat probe passes on Windows after :canary tag refresh

🤖 Generated with Claude Code

When jtag is invoked via the install.sh-created symlink at
/home/joel/.local/bin/jtag, BASH_SOURCE[0] is the symlink path. dirname
on that gives /home/joel/.local/bin, so neither dist/cli-bundle.js nor
cli.ts can be found there. Silent miss → tsx fallback fires
 → ERR_MODULE_NOT_FOUND → chat
probe fails.

Use readlink -f to walk the symlink chain to the real src/jtag, so
SCRIPT_DIR resolves to the actual src/ directory regardless of
how the user invoked the script. Bundle check + tsx fallback both
work whether jtag was run directly (./jtag) or via the symlinked
PATH entry (jtag).

Caught locally by carl-install-smoke on Windows/bigmama-1 today
(continuum-b69f, 2026-05-03). Earlier fix #93 (36e85d2) only
covered the direct-./jtag case from Phase 4 chat-probe — left
the much more common symlinked-PATH case still broken.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joelteply joelteply merged commit 01d8927 into canary May 3, 2026
3 checks passed
@joelteply joelteply deleted the fix/jtag-resolve-symlink-script-dir branch May 3, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant