Repository navigation
fix(doctor): stop false FAIL on marketplace installs missing CLAUDE_PROJECT_DIR - #213
Merged
Merged
Conversation
…ROJECT_DIR doctor.sh runs through the Bash tool, not as a hook, so it never receives CLAUDE_PROJECT_DIR (Claude Code exports that to hooks only). resolve-paths.sh correctly refuses to guess and fatals — right for the hooks, wrong for a read-only diagnostic, which reported a healthy install as broken while commands/doctor.md forbids questioning the FAIL it produces. Scoped the default to doctor.sh only: default CLAUDE_PROJECT_DIR to $PWD before sourcing resolve-paths.sh, never in resolve-paths.sh itself, so the hooks keep the strict no-guess refusal (pinned in new test_resolve_paths.py). The assumption is never silent: the Paths section prints a WARN naming the assumed directory instead of an OK, and every VERDICT line carries the same disclosure inline. Reported by @PedroHenriqueNS (#207). Co-Authored-By: Max <noreply>
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
Closes #207.
doctor.shruns through the Bash tool viacommands/doctor.md, not as a hook. Claude Code exportsCLAUDE_PROJECT_DIRto the three hooks; it is unset in the Bash tool's environment.resolve-paths.shthen hits its "cannot guess" branch and fatals — correct for the hooks (a wrong guess there writes memory into the wrong project) but wrong for a read-only diagnostic, which reportedFAIL Path resolution failedandVERDICT: problem — capture cannot runon installs where capture was working fine.commands/doctor.mdtells the model to relay the report verbatim and never contradict aFAILline, so the false signal reached the user with no way to question it — the exact failure class the doctor exists to end (#144, #200), now coming from the doctor itself.The judgment call
The obvious fix — default
CLAUDE_PROJECT_DIRinresolve-paths.sh— was rejected. That file refuses to guess on purpose: for its real callers (the three hooks), a wrong guess silently writes memory into the wrong project, which is worse than the doctor's false FAIL. Weakening it there to fix a diagnostic-only bug would trade a loud false-positive for a quiet false-negative elsewhere.The default is instead scoped to
doctor.shalone, applied beforeresolve-paths.shis sourced.resolve-paths.shitself is untouched — pinned by a newtests/test_resolve_paths.py, which asserts the strict refusal (loudexit 1by default,return 1underREMEMBER_PATHS_SOFT_FAIL=1) still holds for every other caller.A silent default would just be a quieter version of the same bug: a doctor confidently reporting on a directory nobody told it about, which may not be the project the operator meant. So the assumption is never presented as fact:
Pathssection now printsWARN CLAUDE_PROJECT_DIR was not set — assumed the current directory: <dir>instead of anOKline.VERDICTline — not just the Paths section — carries the same disclosure inline, since that's the one linecommands/doctor.mdtells the operator to trust without re-deriving anything above it.VERDICT: capture is working — … (CLAUDE_PROJECT_DIR was not set; this describes <dir>, assumed from the current directory)— a WARN-with-named-assumption, not a FAIL and not a silent confident OK.The doc-comment's
default: .was correct as an intent, just never implemented; it's now true, and theENVIRONMENTheader indoctor.shhas been updated to describe the visible-assumption behavior rather than a bare default.Untrusted input handling
Reported by @PedroHenriqueNS (outside the maintainer allowlist). Their reproduction and root-cause analysis were correct and verified independently against the current
main. Their suggested one-line patch (defaulting insideresolve-paths.shitself) was not applied as-is — see judgment call above for why that would have been the wrong scope.Test plan (TDD)
Red first, then green — see commit for the sequence:
tests/test_doctor.py::test_missing_claude_project_dir_does_not_false_fail_on_healthy_install— reproduces the real condition:CLAUDE_PROJECT_DIRunset andCLAUDE_PLUGIN_ROOTpointing at the repo checkout itself (not a.claude/remember/layout), which is what actually forces the fatal branch. Failed onmainwith the exact reportedFAIL/VERDICTtext; passes after the fix, and asserts the assumption is visible (OK CLAUDE_PROJECT_DIRmust NOT appear;assummust appear).tests/test_doctor.py::test_claude_project_dir_set_behaves_unchanged— regression guard: whenCLAUDE_PROJECT_DIRis provided, output is unchanged from before this fix.tests/test_resolve_paths.py(new) — pinsresolve-paths.sh's own strict refusal for non-doctor callers, both underREMEMBER_PATHS_SOFT_FAIL=1and the loud default.Full suite:
924 passed, 41 skippedlocally (python3 -m pytest, ~6m26s), coverage 93.98% (gate 80%).doctor.shresolve-paths.shstrict-refusal invariant pinned and unchanged[Unreleased], crediting @PedroHenriqueNS