Skip to content

Warn from clau link when the link dir is not on PATH - #9

Merged
usmanbashir merged 1 commit into
mainfrom
link-path-hint
Oct 28, 2026
Merged

usmanbashir merged 1 commit into
mainfrom
link-path-hint

Conversation

@usmanbashir

Copy link
Copy Markdown
Owner

Summary

clau link reported success even when the folder it had just filled wasn't on PATH. The README Quick start (clau link, then co5) then failed with command not found for anyone without ~/.local/bin on PATH, such as on stock macOS or with a Homebrew or npm install of Claude Code. Only clau doctor mentioned it, and a first-time user has no reason to run it yet.

link now prints a hint to stderr after its summary whenever the folder isn't on PATH:

$ clau link
linked 25, kept 0, skipped 0, pruned 0 in /Users/me/.local/bin
clau: ~/.local/bin is not on PATH, so these commands won't be found; add it to PATH in your shell config (clau doctor re-checks)

The PATH check is shared with doctor now, and it no longer warns falsely about a PATH entry that reaches the folder through a symlink, or on Windows about one that differs only in letter case.

Closes #8.

Changes

  • link.go: new dirOnPath(dir). It compares each non-empty PATH entry with dir using os.Stat + os.SameFile. If either path can't be stat'ed, it falls back to comparing filepath.Clean strings, which covers the folder before the first link.
  • commands.go: doctorFindings calls dirOnPath instead of its inline string comparison. The messages are unchanged.
  • main.go: cmdLink prints the hint on every run, not only when it made new links. The path is shown through contractHome.
  • link_test.go: dirOnPath tests for an exact entry, a trailing separator, an absent folder, a parent-only entry, a symlinked entry in both directions, a missing folder falling back to strings, and (Windows only) an entry differing only in case.
  • commands_test.go: TestDoctorLinkDirThroughSymlink checks that doctor says "is on PATH" when PATH reaches the folder through a symlink.
  • integration_test.go: TestIntegrationLinkHintsWhenDirOffPath runs the built binary with a temp HOME. With the folder off PATH, the hint appears on the first run and on a rerun that links nothing. With it on PATH, there's no hint. stdout is byte-identical in both cases, and every run exits 0.

Behavior notes

  • stdout and the exit code are unchanged, so anything that parses the summary line keeps working.
  • The hint gives no shell-specific instructions, since clau doesn't detect the shell.
  • The README's clau doctor sentence stays as it is.
  • unlink is unchanged.

Test plan

  • The new tests fail before the fix: no hint in either off-PATH run, and doctor warns "not on PATH" for the symlinked entry. They pass with it.
  • By hand, with a fresh build, a temp HOME and a PATH without ~/.local/bin: link prints the hint and exits 0, a rerun prints it again, co5 is not found, and doctor warns. With ~/.local/bin on PATH, a fresh link prints no hint, its stdout matches the off-PATH run byte for byte, and co5 resolves. Through a symlinked home on PATH, link and doctor both treat the folder as on PATH. Before the first link, doctor matches a .local/bin/ entry by its spelling.
  • go test -count=1 ./..., go vet ./... and gofmt -l . are clean. GOOS=windows and GOOS=darwin go vet and go test -c succeed.
  • The Windows case-folding test runs only on the windows-latest CI job.

clau link printed its summary and exited 0 even when the folder it had
just filled was not on PATH, so the README Quick start (clau link, then
co5) ended in "command not found" and only clau doctor said why. link
now prints a hint to stderr after the summary, on every run; stdout and
the exit code are unchanged.

The check moves out of doctorFindings into dirOnPath, which both use.
It matches PATH entries by file identity, so an entry that reaches the
folder through a symlink (/home -> /var/home) or, on Windows, in another
letter case no longer draws a false warning from doctor. When either
path can't be stat'ed, such as the folder before the first link, it
compares the cleaned paths as before.
@usmanbashir
usmanbashir marked this pull request as ready for review October 28, 2026 04:52
@usmanbashir
usmanbashir merged commit fbcc179 into main Oct 28, 2026
4 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.

clau link: warn when the link directory isn't on PATH

1 participant