Repository navigation
Warn from clau link when the link dir is not on PATH - #9
Merged
Merged
Conversation
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
marked this pull request as ready for review
October 28, 2026 04:52
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
clau linkreported success even when the folder it had just filled wasn't on PATH. The README Quick start (clau link, thenco5) then failed withcommand not foundfor anyone without~/.local/binon PATH, such as on stock macOS or with a Homebrew or npm install of Claude Code. Onlyclau doctormentioned it, and a first-time user has no reason to run it yet.linknow prints a hint to stderr after its summary whenever the folder isn't on PATH:The PATH check is shared with
doctornow, 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: newdirOnPath(dir). It compares each non-empty PATH entry withdirusingos.Stat+os.SameFile. If either path can't be stat'ed, it falls back to comparingfilepath.Cleanstrings, which covers the folder before the first link.commands.go:doctorFindingscallsdirOnPathinstead of its inline string comparison. The messages are unchanged.main.go:cmdLinkprints the hint on every run, not only when it made new links. The path is shown throughcontractHome.link_test.go:dirOnPathtests 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:TestDoctorLinkDirThroughSymlinkchecks that doctor says "is on PATH" when PATH reaches the folder through a symlink.integration_test.go:TestIntegrationLinkHintsWhenDirOffPathruns the built binary with a tempHOME. 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
clau doctorsentence stays as it is.unlinkis unchanged.Test plan
HOMEand a PATH without~/.local/bin:linkprints the hint and exits 0, a rerun prints it again,co5is not found, anddoctorwarns. With~/.local/binon PATH, a freshlinkprints no hint, its stdout matches the off-PATH run byte for byte, andco5resolves. Through a symlinked home on PATH,linkanddoctorboth treat the folder as on PATH. Before the first link,doctormatches a.local/bin/entry by its spelling.go test -count=1 ./...,go vet ./...andgofmt -l .are clean.GOOS=windowsandGOOS=darwingo vetandgo test -csucceed.windows-latestCI job.