fix(detector): resolve symlinks when classifying the system node#113
Merged
Conversation
The system-node classifier matched exec.LookPath's result against manager roots and path patterns without ever resolving symlinks. fnm is the canonical casualty: its shell integration puts a per-shell multishell shim dir on PATH ($FNM_MULTISHELL_PATH/bin), so the node nodeup finds symlink-resolves into $FNM_DIR but shares no path prefix with it — and the user's own manager-owned node reported as "unrecognized layout", a kind the cleanup logic treats as safe to overwrite. ResolveSystemNode now resolves the PATH entry once (new evalSymlinks seam) and consults both locations: manager roots match either path, while path-pattern classification still prefers the unresolved path and only consults the resolved one when the original is unrecognized — resolution can upgrade a classification, never downgrade one (Debian's /usr/bin/node -> /etc/alternatives symlink stays os-package). managerManagedRoots additionally recognizes the fnm multishell farm dirs ($FNM_MULTISHELL_PATH and its parent, $XDG_STATE_HOME / ~/.local/state / legacy $TMPDIR fnm_multishells) so the farm classifies as fnm-owned even when resolution fails. Verified live: nodeup check now reports the fnm multishell node as "managed by fnm". Refs #111 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
filepath.Dir rewrites separators, so the Windows runner got \state\fnm_multishells where the table expected the forward-slash literal. Mirror production by computing the expectation with filepath.Dir. Refs #111 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
✔️ 95ace76...6ce416b - Conventional commits check succeeded. |
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
Resolve symlinks when classifying the
nodefound on PATH, and teach the classifier fnm's multishell farm dirs — so an fnm shim (~/.local/state/fnm_multishells/<id>/bin/node) classifies asmanaged by fnminstead ofunrecognized layout, a kind the cleanup logic treats as safe to overwrite. Closes #111Linked issues
Closes #111
Type of change
feat— new feature (MINOR bump)fix— bug fix (PATCH bump)refactor— no behavior changeperf— performance improvementdocs— documentation onlytest— tests onlychore— maintenance / dependency bumpci— CI/CD onlybuild— build system onlyChecklist
feat(scope): subject)make cilocally and it passesdocs/, inline godoc)Scope notes
unknown. This keeps Debian's/usr/bin/node → /etc/alternatives/nodecorrectlyos-package(pinned by a new test).evalSymlinksis a package seam (likewhichNode/getenv) so tests use canned resolutions instead of real symlinks, which need elevated rights on Windows runners.SystemNodeInfo.Pathkeeps the original PATH entry for display; only classification consults the resolved location.$FNM_MULTISHELL_PATH(plus its farm parent, catching sibling instances from other shells),$XDG_STATE_HOME/fnm_multishells,~/.local/state/fnm_multishells, and the legacy$TMPDIR/fnm_multishells.Screenshots / output
Before:
System node: /Users/dipto/.local/state/fnm_multishells/79731_.../bin/node (unrecognized layout)After:
System node: /Users/dipto/.local/state/fnm_multishells/79731_.../bin/node (managed by fnm)— verified live on the reporting machine.🤖 Generated with Claude Code