Skip to content

Fix Windows uninstall, shell-integration cleanup, and Windows autocomplete - #20

Merged
Kaushik2003 merged 3 commits into
mainfrom
win-fix
Jun 3, 2026
Merged

Kaushik2003 merged 3 commits into
mainfrom
win-fix

Conversation

@Kaushik2003

Copy link
Copy Markdown
Contributor

Summary

Makes the install/uninstall lifecycle work correctly and symmetrically across Windows, macOS, and Linux.

  • Windows uninstall now works. The binary lives inside the config dir, and Windows locks a running .exe, so os.RemoveAll(configDir) aborted with "Access is denied" and left everything behind. Config/DB are now removed first (skipping the running exe), then a detached helper deletes the locked binary + directory once the process exits. Unix unlinks the running binary directly.
  • Uninstall reverses shell integration. Strips the # StacyVM Autocomplete block from .bashrc/.zshrc/fish config, removes the .stacyvm\bin entry from the Windows User PATH, and strips the PowerShell profile block — only touching StacyVM's own lines. Fixes the "stacyvm: command not found" noise in new shells after uninstall.
  • Windows autocomplete now installs. setup previously only wrote to .bashrc/.zshrc/fish (absent on Windows), so completion was silently skipped. It now installs into the PowerShell profile(s) (powershell.exe and pwsh) via each shell's real $PROFILE.CurrentUserAllHosts.

Testing

  • Builds clean on windows/linux/darwin; go vet passes.
  • New unit tests for autocomplete-block removal (bash, fish, PowerShell, legacy, absent).
  • Verified end-to-end on Windows 11: uninstall removes exe + .stacyvm dir + PATH entry + profile block, with the profile restored byte-for-byte to its pre-install state.

Closes #17
Closes #18
Closes #19

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread cmd/stacyvm/cmd_setup.go Fixed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the install/uninstall lifecycle across platforms, focusing on making Windows uninstall reliable (despite locked running .exe files) and ensuring shell integration (PATH + autocomplete) is cleaned up symmetrically on uninstall. It also modernizes Docker provider defaults to work correctly on Windows by relying on Docker client environment/platform defaults rather than hard-coded unix sockets.

Changes:

  • Implement Windows-safe uninstall by deleting config contents first (skipping the running binary) and scheduling post-exit removal of the locked .exe via a detached helper.
  • Add symmetric shell-integration cleanup during uninstall (remove autocomplete blocks from shell rc/profile files and remove the Windows User PATH entry).
  • Improve setup/install ergonomics: PowerShell completion installation on Windows and Docker client configuration (API negotiation + env/platform host defaults).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/npm-setup.mjs Improves setup UX (TTY-safe spinner/progress) and adds better cross-platform dependency guidance; fixes Windows command spawning and PATH handling in the setup script.
internal/providers/docker.go Switches Docker client to API version negotiation and uses env/platform default host when no socket is configured (fixes Windows).
internal/config/config.go Makes Docker socket default empty so the Docker client selects the correct platform host / honors DOCKER_HOST.
cmd/stacyvm/cmd_uninstall.go Implements config-dir deletion that skips the running binary; adds autocomplete-block removal helpers invoked during uninstall.
cmd/stacyvm/cmd_uninstall_windows.go Adds Windows-specific shell cleanup and deferred self-delete via detached batch helper.
cmd/stacyvm/cmd_uninstall_unix.go Adds Unix-specific shell cleanup and immediate unlink of the running binary.
cmd/stacyvm/cmd_uninstall_test.go Adds unit tests for autocomplete-block removal across bash/fish/PowerShell and legacy cases.
cmd/stacyvm/cmd_setup.go Adds Windows PowerShell completion install path discovery and writing to PowerShell profiles.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/stacyvm/cmd_uninstall.go
Comment thread cmd/stacyvm/cmd_uninstall_windows.go Outdated
- writePowerShellCompletion: handle WriteString/Close errors explicitly
  instead of deferring Close on a writable handle.
- removeAutocompleteFromFile: preserve the existing file mode when
  rewriting so an 0600 profile isn't widened to 0644.
- scheduleSelfDelete: use os.CreateTemp for a unique cleanup .bat name
  instead of a predictable, collision-prone temp filename.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread cmd/stacyvm/cmd_uninstall.go
Comment thread cmd/stacyvm/cmd_uninstall.go
- sameFile: compare paths case-insensitively on Windows so a casing
  difference (e.g. drive letter) between os.Executable() and a directory
  walk doesn't make removeAllExcept fail to skip the locked running .exe.
  isWithin already folds case via filepath.Rel, so only this needs it.
- isAutocompleteBlockLine: restrict the legacy no-terminator match set to
  StacyVM-specific tokens (stacyvm, .local/bin) so it can't delete
  unrelated user config lines containing generic tokens like source.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Kaushik2003
Kaushik2003 marked this pull request as ready for review June 3, 2026 21:25
@Kaushik2003
Kaushik2003 merged commit 74f342e into main Jun 3, 2026
16 checks passed

This branch was successfully deployed

1 active deployment
staging — a00ae4d4 Deployed Jun 2, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants