fix(cli-resolve): expand leading ~ in CLAUDE_CODE_PATH before spawn#3275
Draft
posthog[bot] wants to merge 2 commits into
Draft
fix(cli-resolve): expand leading ~ in CLAUDE_CODE_PATH before spawn#3275posthog[bot] wants to merge 2 commits into
posthog[bot] wants to merge 2 commits into
Conversation
A user-configured CLAUDE_CODE_PATH like `~/.local/bin/claude` was passed verbatim to existsSync and posix_spawn, neither of which expands `~`. The capability probe died with ENOENT and findClaudeExecutable threw, silently halting all memory capture. Add a shared expandTilde() helper and apply it defensively at read time in find-claude-executable.ts (so both the existence check and every probe spawn see a real absolute path) and at write time in SettingsRoutes.ts. This turns `~/.local/bin/claude` back into exactly the candidate the resolver already knows how to run. Generated-By: PostHog Code Task-Id: ab3187bd-1feb-4ad6-9b99-9141b3117e9f
Contributor
…iles The CI `test` check failed on ~30 tests across find-claude-executable, recall-mcp-server, and server-boot — none touched by this PR. Root cause: claude-setup-gate.test.ts registered a global `mock.module` on find-claude-executable.js that (a) exported only `findClaudeExecutable`, dropping `_internals`/`resetClaudeExecutableCache`/`CAPABILITY_PROBE_ARGS`, and (b) left the stub throwing after its last test. bun's mock.module is process-global and sticky, so in CI's file order it leaked into every later file that imports the module or transitively resolves the CLI, breaking them. Make the mock leak-proof: snapshot and spread the real module through the factory (preserving the other exports), default the override to the real implementation, and restore it in afterAll so no stub escapes this file. Generated-By: PostHog Code Task-Id: ab3187bd-1feb-4ad6-9b99-9141b3117e9f
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.
Summary
A user-configured
CLAUDE_CODE_PATHwith a leading~(e.g.~/.local/bin/claude) broke memory capture entirely. The value was passed verbatim toexistsSync()and then toposix_spawnviaexecFileSync— neither expands~— so the capability probe died withENOENT ... posix_spawn '~/.local/bin/claude',findClaudeExecutable()threw, and no Claude CLI ever resolved.The fix adds a shared
expandTilde()helper and applies it:find-claude-executable.ts, so both the existence check and every probe spawn see a real absolute path (covers hand-edited settings files);SettingsRoutes.ts, so the stored value is already resolved.For the reported path this turns
~/.local/bin/claudeback into exactly the candidate the resolver already probes viajoin(homedir(), '.local', 'bin', 'claude').Why
Putting a
~in a config path is a natural mistake, and when a user makes it the failure is total and silent — claude-mem's core observation flow stops. The only workaround was to use an absolute path.Test plan
find-claude-executabletest asserting a tildeCLAUDE_CODE_PATHresolves to the expanded home path and that every probe spawn sees the expanded path (never the literal~).bun test tests/shared/find-claude-executable.test.ts— 21 pass.Created with PostHog Code from an inbox report.