Skip to content

Fix: Version shows incorrectly after CLI update on Unix/macOS #33

@avivsinai

Description

@avivsinai

Problem

After running promptcode update on Unix/macOS systems, the first --version command shows the old version instead of the new one. The user must run --version twice to see the correct version.

Root Cause

The update process stages the new binary as .new and applies it on the next run. However, when the old binary finalizes the update (swaps files), it continues running with its baked-in old version string.

Solution

Implement re-exec after finalization: After successfully swapping binaries, the process should re-execute itself with the same arguments, ensuring the new binary handles the command.

Implementation

  • Use spawnSync instead of execSync for safer execution
  • Add exclusive locking to prevent race conditions
  • Properly propagate exit codes and signals
  • Implement atomic operations with rollback capability
  • Handle symlinks, permissions, and platform differences correctly

This ensures promptcode --version shows the correct version immediately after an update.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions