feat(cmd): add doctor command for diagnosing configuration issues#261
Merged
Conversation
Add `dtvem doctor` and supporting framework. Diagnoses nine classes of dtvem misconfiguration, splitting findings into [fixable] (doctor knows how to remediate) and [manual] (step-by-step instructions). Default mode is read-only; `--fix` opts into interactive remediation and `--yes` skips per-finding prompts. Exits non-zero when any error-severity finding is present so CI scripts can react. Checks: stale-shims-path (fixable: User PATH registry on Windows, shell-config marker-block removal on Unix), shims-in-path, shim-binary-present, empty-shims-directory (fixable: reshim), shim-map-cache (fixable: reshim, with post-fix drift check that surfaces orphan shim files reshim can't resolve), system-runtime-precedence, xdg-split-state, configured-runtimes-installed, runtime-executable-present. Adds internal/path helpers RemoveStaleShimsFromUserPath (Windows, no admin) and RemoveStaleShimsFromShellConfig (Unix, only touches lines preceded by the `# Added by dtvem` marker) so the stale-shims-path fix can run targeted writes without re-using the init-time PATH helpers, which bundle removal with re-ordering.
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
Adds
dtvem doctor, a diagnostic command that runs nine checks against a dtvem installation and reports findings as[fixable](doctor can remediate) or[manual](step-by-step instructions). Default mode is read-only;--fixenables interactive remediation, and--yesskips per-finding prompts. Exits non-zero when any error-severity finding is present so CI scripts can react.Checks
stale-shims-pathshims-in-pathdtvem init)shim-binary-presentempty-shims-directoryshim-map-cachesystem-runtime-precedencexdg-split-stateconfigured-runtimes-installeddtvem install <r> <v>)runtime-executable-presentFramework
src/internal/doctor/contains the framework —Checkinterface,Finding/Detail/Severitytypes, aRegistrywithinit()-time registration (same pattern as runtime/migration providers), and aRunaggregator withHasErrors()andFixable()helpers. Adding a new check is one Go file plus aRegister(...)call ininit().Path helpers
Two new helpers in
internal/pathback the stale-shims fix:RemoveStaleShimsFromUserPath(Windows-only): rewrites the User PATH registry value to drop stale dtvem-shims entries while preserving every other entry's order. No admin required. Stale entries in System PATH still need an elevated terminal and aren't auto-touched.RemoveStaleShimsFromShellConfig(cross-platform, called only from Unix branch): only deletes pairs of lines where the first is exactly the# Added by dtvemmarker, so user-edited PATH exports are never touched even if they happen to reference an old dtvem path.Both share a new pure helper
PartitionStaleShimsEntries, which complements the existingFindStaleShimsEntries.Test plan
./rnr checkpasses (format, lint, all tests)dtvem doctorruns all checks read-only and prints a report[fixable]/[manual]tagsdtvem doctor --fix --yesapplies fixable findings non-interactivelydtvem doctor --fix --no-fixerrors with exit code 2python3.exeshim with no installed-version executable to back it); the post-fix drift check correctly surfaced the orphan filename rather than falsely claiming FixedResolves #248