Skip to content

fix: handle removing active versions#163

Merged
hendriknielaender merged 2 commits into
hendriknielaender:mainfrom
KercyDing:fix/rm-installed
May 20, 2026
Merged

fix: handle removing active versions#163
hendriknielaender merged 2 commits into
hendriknielaender:mainfrom
KercyDing:fix/rm-installed

Conversation

@KercyDing

Copy link
Copy Markdown
Contributor

Summary

Closes #162.

This PR fixes the case where removing the currently active Zig/ZLS version looks like it hangs.

The confirmation prompt now shows normally, y continues immediately, and Ctrl+C exits while waiting for input.

After removing the active version, zvm leaves that tool with no active version selected. The shim stays in place and prints a clear error if there is no active version.

Main changes:

  • disable progress rendering for remove
  • make confirmation prompts read one line instead of waiting for the whole fixed buffer
  • make blocking prompts exit on Ctrl+C
  • clear Zig default_version when the removed active Zig version matches it
  • keep zig / zls shims after removing the active version
  • show a clear no-active-version message from the shim
  • add e2e coverage for removing active Zig and ZLS versions

Verification

picture picture

@KercyDing KercyDing marked this pull request as ready for review May 18, 2026 19:16
Copilot AI review requested due to automatic review settings May 18, 2026 19:16

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

Fixes the hang and unresponsive Ctrl+C when removing the currently active Zig/ZLS version. The confirmation prompt is now visible (progress rendering disabled for remove), reads a single line so y+Enter returns immediately, can be interrupted by Ctrl+C, and the removal correctly clears default_version while leaving the shim in place with a clear "no active version" message.

Changes:

  • Make the destructive-confirmation prompt non-blocking-friendly: read until newline and exit on Ctrl+C via new signals.begin/end_blocking_wait helpers; disable progress rendering when progress_items returns 0 (now the case for remove).
  • On removing the active Zig version, clear the default_version file; keep shims in place and have them report a clear "No active … version selected" error.
  • Add e2e coverage for removing the active Zig and ZLS versions, plus assert_path_exists / assert_path_missing helpers.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/util/confirm.zig Switch to line-delimited read and wrap stdin wait with signal helpers so Ctrl+C interrupts.
src/platform/signals.zig Add begin/end_blocking_wait and exit on interrupt if a blocking wait or already-requested interrupt is in progress.
src/main.zig Move shim dispatch after output-mode setup; disable progress printing when progress_item_count == 0.
src/core/remove.zig New clear_default_if_active to delete default_version when removing the active Zig version.
src/core/remove_installed.zig Return 0 progress items so progress UI is suppressed for remove.
src/shim.zig Detect missing tool path and print a clear "no active version" error instead of a raw FileNotFound.
tests/e2e.zig New e2e tests for removing active Zig/ZLS versions and path-existence assertion helpers.
Comments suppressed due to low confidence (1)

tests/e2e.zig:753

  • Same comptime format-mismatch as in test_remove_active_zig: the format string "{s}{c}.zm{c}bin{c}{s}" has 5 placeholders but 6 arguments are passed (one extra std.fs.path.sep). This will fail to compile under std.fmt.bufPrint's comptime checks.
    var shim_path_buffer: [sandbox_path_max]u8 = undefined;
    const shim_path = try std.fmt.bufPrint(
        &shim_path_buffer,
        "{s}{c}.zm{c}bin{c}{s}",
        .{ sandbox, std.fs.path.sep, std.fs.path.sep, std.fs.path.sep, zls_name },
    );

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

Comment thread tests/e2e.zig

@hendriknielaender hendriknielaender left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

looks great to me 👍

@KercyDing

Copy link
Copy Markdown
Contributor Author

Ready for review❤️

@hendriknielaender hendriknielaender merged commit ac019bd into hendriknielaender:main May 20, 2026
11 of 12 checks passed
@KercyDing KercyDing deleted the fix/rm-installed branch May 20, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Removing the active version appears to hang and Ctrl+C does not interrupt

3 participants