fix(axi-sdk-js): use absolute path for hooks when CLI installed via a Node version manager - #110
Open
sholsinger wants to merge 1 commit into
Open
Conversation
… Node version manager resolvePortableHookCommand preferred the bare binary name whenever it resolved on PATH at install time. But Node version managers (nvm, nvs, fnm, asdf, Volta, nodenv) add their bin directory to PATH only from interactive shell startup files. Agent SessionStart hooks run under a non-interactive shell (`/bin/sh -c`) that never sources those files, so the bare name is "command not found" when the hook fires. Skip version-manager bin directories when choosing the command so the resolver falls back to the absolute exec path, which does not depend on an interactively-augmented PATH. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
<tool> setup hooks(e.g.jira-axi setup hooks,confluence-axi setup hooks) registers a Claude CodeSessionStarthook that fails on every session start with:...even though
jira-axiworks fine in the user's terminal.Root cause
resolvePortableHookCommandprefers the bare binary name (jira-axi) whenever that name resolves onprocess.env.PATHat install time. When the CLI is installed through a Node version manager (nvm, nvs, fnm, asdf, Volta, nodenv), the manager's activebindirectory is only added toPATHby interactive shell startup files (~/.zshrc,~/.bashrc, fnm/asdf shell hooks).Claude Code runs
SessionStarthooks under a non-interactive shell (/bin/sh -c "<command>") that never sources those files, so the version-managerbindir is absent fromPATHand the bare name iscommand not found. The install-time PATH ≠ the hook-execution-time PATH.Fix
Skip version-manager-managed directories when choosing the hook command. When the bare name only resolves via such a directory, the resolver falls back to the absolute exec path it already computes — which does not depend on an interactively-augmented
PATH. If the binary is also reachable from a stable system dir (e.g./usr/local/bin), the short portable name is still used.Detected via path segment match:
.nvm,.nvs,.fnm,fnm_multishells,.asdf,.volta,.nodenv.Tests
resolvePortableHookCommandreturns the absolute path when the binary only resolves via an nvm dir (regression for the reported bug).isVersionManagerPathEntryhelper.tscbuild,vitest(125/125),prettier --check, andeslinton the changed files all pass.Known limitation (out of scope)
If Node itself is reachable only via a version manager (no system
nodeon the non-interactive PATH), the absolute-script command's#!/usr/bin/env nodeshebang would still fail to findnode. A fully robust fix would anchor the command onprocess.execPath, but that reintroduces version-pinning trade-offs, so it's left as a follow-up.🤖 Generated with Claude Code