Repository navigation
feat(install): add uninstall scripts - #302
Merged
Merged
Conversation
Add uninstall.sh (macOS/Linux) and uninstall.ps1 (Windows) to remove everything dtvem puts on a machine: - every dtvem root (DTVEM_ROOT, XDG_DATA_HOME/dtvem, ~/.local/share/dtvem, ~/.dtvem), with all installed runtime versions - the PATH changes made by the installers and `dtvem init`: the marked blocks in shell config files on Unix, and the User and System PATH entries on Windows (REG_EXPAND_SZ and %VAR% entries preserved, one UAC prompt when the System PATH needs editing) - on Windows, what RubyInstaller registered when older dtvem versions used its .exe to install Ruby: Programs and Features entries, Start menu folders, PATH entries and the .rb/.rbw file associations Both scripts list what they will remove and ask first (--yes / -Yes skips the prompt). They refuse /, a drive root and the home directory, only remove dtvem's own entries from a custom DTVEM_ROOT, and never follow links or junctions out of the root. Lint both scripts in script-lint.yml, publish them as release assets, and add an integration test that installs dtvem as the installers do, uninstalls it, and checks nothing is left on Linux, macOS (bash 3.2), and Windows (pwsh and Windows PowerShell 5.1).
The Windows uninstall test expected the System PATH to still be REG_EXPAND_SZ afterwards, but GitHub's Windows runner images store it as REG_SZ with no %VAR% entries, so the check failed although the uninstaller kept the value's type. Make the System PATH REG_EXPAND_SZ with a %SystemRoot% entry before `dtvem init`, log the type it had, and check the uninstaller keeps both the type and the unexpanded entry, as the User PATH check already does.
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.
Description
Adds
uninstall.sh(macOS/Linux) anduninstall.ps1(Windows), the counterparts of the install scripts. They remove everything dtvem puts on a machine, after listing it and asking for confirmation (--yes/-Yesskips the prompt):curl -fsSL dtvem.io/uninstall.sh | bashType of Change
Related Issues
None.
Changes Made
uninstall.sh/uninstall.ps1remove:DTVEM_ROOT,$XDG_DATA_HOME/dtvem,~/.local/share/dtvem,~/.dtvem, including all installed runtime versions and their global packagesdtvem init:# Added by dtvem/# Added by dtvem installerblocks in shell config files. Other lines that mention dtvem are listed, never edited. Config files that are symlinks stay symlinks, and CRLF files are handled.REG_EXPAND_SZ(aswritePathValuedoes), so%VAR%entries keep working. If the System PATH needs editing, there is one UAC prompt..exe. That means Programs and Features entries, Start menu folders, PATH entries and the.rb/.rbwassociations, all pointing at a deleted%TEMP%\dtvem-ruby-<version>./, a drive root and the home directory.DTVEM_ROOTnot nameddtvem/.dtvemonly loses dtvem's own entries (shims,versions,config,cache,tmp,bin/dtvem*).npm linktargets) are removed without touching what they point to. On Windows this usesrd /s /q, becauseRemove-Itemin PowerShell 5.1 can follow a junction, and .NET'sDirectory.Deletefails on read-only files.script-lint.yml: lints the uninstall scripts with ShellCheck and PSScriptAnalyzer.integration-test-uninstall.yml(new):dtvem initdo./bin/bash3.2, and Windows under bothpwshand Windows PowerShell 5.1.release.yml: publishesuninstall.shanduninstall.ps1as release assets next to the install scripts.Testing
Test Environment
Test Steps
uninstall.sh: 15 checks with a fakeHOMEunder Git Bash.DTVEM_ROOT=$HOMEis refused.uninstall.ps1: 31 checks of its functions under both PowerShell 7.6 and 5.1.'and‘’in paths.~/.dtvemand its PATH entries, plus the RubyInstaller leftovers from an old dtvem Ruby install: two Programs and Features entries, two Start menu folders, the.rb/.rbwassociation and two dead System PATH entries. Nothing was removed../rnr checkpasses.Test Results
Checklist
golangci-lint runand fixed all issues (includes gofmt, govet, and 40+ linters)go mod tidyto clean up dependencies (no dependency changes)go test ./...)Breaking Changes
N/A
Additional Notes
script-lint.ymlrun is the first lint.dtvem.io/uninstall.*URLs work: after a release that includes the new assets, and after the dtvem.io worker redirects/uninstall.shand/uninstall.ps1(in progress in the dtvem.io repo). Until then, the raw GitHubmainURLs in the scripts' headers work.uninstall.ps1is ASCII-only: Windows PowerShell 5.1 reads a script file without a BOM in the ANSI code page, where the UTF-8 bytes of→ ✓ ✗include quote characters.install.ps1has this problem today when run with-Fileon 5.1 (irm | iexis unaffected). That's worth a separate fix.By submitting this pull request, I confirm that my contribution is made under the terms of the project's MIT License and I agree to follow the Code of Conduct.