Add vastai uninstall command for managed installs - #472
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new vastai uninstall subcommand intended for managed (installer-based) installations, alongside updates to the hidden-command discoverability gate and new test coverage to validate uninstall behavior and help visibility.
Changes:
- Adds
vastai uninstallcommand with confirmation/--yesbehavior and refusal for non-managed installs. - Implements managed-uninstall filesystem logic in
perform_uninstall()(remove install root + relevant~/.local/binsymlinks). - Extends hidden-command coverage so
update/uninstallare excluded from--helpwhile still parsing, plus new uninstall-focused tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vastai/cli/selfupdate.py | Adds LOCAL_BIN constant and perform_uninstall() to remove managed install root + symlinks. |
| vastai/cli/main.py | Registers the new uninstall command module so it loads with other CLI commands. |
| vastai/cli/commands/update.py | Marks update as hidden=True to hide it from --help/completion while still runnable. |
| vastai/cli/commands/uninstall.py | Implements vastai uninstall command parsing, confirmation prompt, and managed-install gating. |
| tests/conftest.py | Loads uninstall in the session-scoped CLI parser fixture for tests. |
| tests/cli/test_uninstall_command.py | Adds unit tests for uninstall command behavior and perform_uninstall() filesystem effects. |
| tests/cli/test_parser.py | Adds tests verifying update/uninstall are hidden from help but still parse directly. |
Comments suppressed due to low confidence (2)
vastai/cli/selfupdate.py:350
- perform_uninstall() currently swallows symlink resolution/unlink errors and uses shutil.rmtree(..., ignore_errors=True), so the uninstall command can report success even when binaries/root were not actually removed (e.g., permission errors, symlink loop). It also compares unresolved root against resolved targets, which can fail when VASTAI_INSTALL_DIR is a symlink.
if link.is_symlink() and root in link.resolve().parents:
link.unlink()
except OSError:
pass
shutil.rmtree(root, ignore_errors=True)
vastai/cli/commands/uninstall.py:64
- This message hard-codes "~/.config/vastai" even when XDG_CONFIG_HOME is set. Using $XDG_CONFIG_HOME here avoids telling users to look in the wrong place for their preserved API key/config.
print("Config in ~/.config/vastai was left untouched.")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+336
to
+340
| Config (~/.config/vastai), cache (~/.cache/vastai), and state | ||
| (~/.local/state/vastai) are left alone — the same guarantee documented | ||
| for a manual ``rm -rf`` (docs/install-design.md §3). Safe to call while | ||
| running from inside ``root``: like the update swap above, removing the | ||
| directory doesn't disturb an already-running interpreter on POSIX. |
Comment on lines
+62
to
+65
| perform_uninstall() | ||
| print(f"vastai {VERSION} uninstalled from {root}.") | ||
| print("Config in ~/.config/vastai was left untouched.") | ||
| return 0 |
Comment on lines
+30
to
+33
| ({INSTALL_SH_HINT}): the install root and its symlinks in | ||
| ~/.local/bin. Config in ~/.config/vastai (your API key) is left | ||
| untouched, so re-running the installer keeps you logged in. | ||
| For pip installs, uninstall with: {PIP_UNINSTALL_HINT} |
Contributor
Author
|
Addressed Copilot's review:
|
vastzuby
approved these changes
Jul 24, 2026
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
vastai uninstall, mirroringvastai update's structure and same-method discipline: on a managed (curl | bash installer) install it removes the install root and its~/.local/binsymlinks while leaving~/.config/vastai(API key), cache, and state untouched; on a pip install it refuses and points atpip uninstall vastaiinstead of shelling out.-y/--yes; refuses in a non-interactive shell without--yes.perform_uninstall()added toselfupdate.pynext to the existingperform_update().updateanduninstallare hidden from--help/tab-completion for now (samehidden=Truediscoverability gate used for the network-volume commands in Hide unreleased network-volume commands from --help #466) — still fully runnable if typed directly, until they've had more real-world testing.Test plan
poetry run pytest tests/cli/— 389 passedtests/cli/test_uninstall_command.pycovers: pip-install refusal,--yesskipping the prompt, non-interactive refusal without--yes, confirm/decline/EOF on the prompt, andperform_uninstall()'s filesystem behavior (removes root, removes only symlinks that resolve into the root, leaves foreign same-named binaries and config alone)test_parser.pyconfirmupdate/uninstallare excluded from--helpbut still parsescripts/dev-install.sh --from-source), confirmeduninstallis hidden from--helpbut runs directly, ranvastai uninstall --yesagainst a real managed install and confirmed the install root was removed and config was left in place, then reinstalled viascripts/install.shand confirmed the wheel-install progress UX still works