Repository navigation
fix(uninstall): allow removing the last installed version - #300
Merged
Merged
Conversation
Install makes the first version of a runtime the global version, and uninstall refused to remove the global version, so the last installed version of a runtime could never be uninstalled. Uninstalling the global version is now allowed when it is the only installed version; the runtime's entry is removed from the global config after the files are deleted. With other versions installed it is still refused, and the message lists them. The "active local version" warning used provider.LocalVersion, which falls back to the global version, so it fired for every global version and named the obsolete dtvem.config.json. It now uses config.Resolve, warns only when a project file pins the version, and names that file.
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.
Problem
dtvem installmakes the first installed version of a runtime the global version, anddtvem uninstallrefused to remove the global version until a different one was set. With only one version installed there is nothing to switch to, so the last version of a runtime could never be uninstalled.Changes
runtimes.jsononce the files are deleted. Other runtimes' entries are kept. Canceling at the prompt leaves everything as it was.config.UnsetGlobalVersionremoves one runtime's entry from the global config. It does nothing when the file or the entry is missing, and it returns an error instead of rewriting a config it cannot parse.provider.LocalVersion(), which falls back to the global version. So it fired for every global version and named the obsoletedtvem.config.json. Uninstall never reached that warning for the global version before, so this change would have exposed it. The warning now usesconfig.Resolve, appears only when a project file (.dtvem/runtimes.json,.tool-versions,.ruby-version, …) pins the version, and names that file.Testing
./rnr checkpasses (format, lint with 0 issues, all tests).UnsetGlobalVersion: removes only the target runtime, leaves valid JSON when the last entry is removed, handles a missing file and a missing entry, and does not rewrite a corrupt config.otherVersionsandlocalPinSource: a global version alone is not a local pin, a project.ruby-versionwith a partial version is a pin, and a pin of a different version is ignored.DTVEM_ROOT:.ruby-version, and it names that file.