Skip to content

Preserve the working CLI installation if a release update fails #38

In review

Description

@sh00kapic

The updater deletes and replaces bin, lib, config and libexec one directory at a time. It checks for the new executable afterwards in the live destination. An archive with a bin directory but no CLI can displace a working binary before validation fails. A failed rename can also leave new executables paired with older libraries.

Expected behavior and verification

Validate the staged release and retain a recoverable previous layout until replacement succeeds. Exercise an invalid archive and a failure partway through replacement. In both cases the previous CLI should still run with its own libraries and the stored version should remain accurate.

ctrace/BinaryUpdater.ts line 286 · ctrace/BinaryUpdater.ts line 307

Activity

  1. added
    bug
    on Nov 20, 2026
  2. Arthurvroum commented on Nov 25, 2026

    @Arthurvroum
    Collaborator

    Fixed on branch 38-safe-cli-update (7e3e5e7), pull request #53.

    • The staged release is validated before anything is touched. If it has no CLI, the installed version stays as it is.
    • The installed bin, lib, config and libexec folders are moved aside and the staged ones moved in. On any failure, the new folders are removed and the old ones are put back. The old copy is deleted only after the new layout is complete.
    • At startup, an update interrupted midway is rolled back, or its leftover copy is deleted if the new release is complete.
    • The stored version is updated only after a successful install.

    Tests: an archive with no CLI, a failure partway through replacement (the previous release is restored with its own libraries), a full replacement, a CLI at the archive root, and recovery after an interrupted update. Unit and workspace suites pass locally (Linux).

    Note: the startup recovery decides whether the new release is complete by checking for the CLI only. A crash between moving in bin and moving in lib would keep the new bin without libraries. This is a narrow case and could be handled separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions