Conversation
Added a major version upgrade warning to all three CLI installation scripts (shell, PowerShell, and Python). When the installed CLI version has a different major version than the target version, the scripts now display a warning message and point users to the CHANGELOG in aptos-core: https://github.com/aptos-labs/aptos-core/blob/main/crates/aptos/CHANGELOG.md The warning is placed at every upgrade code path in each script: - Shell: binary install, source install with version, source install latest - PowerShell: binary install path - Python: get_version(), run_from_source(), install_from_source()
Before overwriting the CLI binary during an upgrade, the install scripts now back up the current binary to <binary>.backup (e.g., aptos.backup). Only one backup copy is kept at a time (overwrites any previous backup). A new --undo flag restores the backup as the current binary: Shell: curl ... | sh -s -- --undo PowerShell: ... --undo Python: python install_cli.py --undo The undo operation is lightweight - no network calls, package installs, or builds are needed. After restoring, the script reports the version that was restored to. Changes across all three scripts (shell, PowerShell, Python): - backup_current_binary / Backup-CurrentBinary / _backup_current_binary - undo_upgrade / Undo-Upgrade / _undo_upgrade - --undo flag in argument parsing - Backup called right before the binary is overwritten in both the binary download and build-from-source install paths
|
Cursor Agent can help with this pull request. Just |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Added comprehensive --help output to all three install scripts: Shell (install_cli.sh): - New show_usage() function with full options reference - -h/--help flag in argument parser - Improved error message for unknown options to mention --help PowerShell (install_cli.ps1): - New Show-Usage function with full options reference - -h/--help handling in argument parser - Improved error message for unknown options to mention --help Python (install_cli.py): - Enhanced argparse description and added epilog section - RawDescriptionHelpFormatter for clean formatting of epilog - Improved all individual help strings for clarity and consistency All three help outputs document: - Every available flag with descriptions - The automatic backup behavior during upgrades - The major version upgrade warning and CHANGELOG link - The --undo rollback mechanism - Usage examples
There was a problem hiding this comment.
Pull request overview
This PR enhances the Aptos CLI installation scripts (sh/py/ps1) to improve upgrade safety and user awareness by adding a one-step rollback mechanism and warning users when crossing major versions (with a link to the CLI changelog).
Changes:
- Add
--undosupport that restores the previously installed CLI binary from a.backupcopy. - Backup the currently installed CLI binary before overwriting it during installation.
- Warn users when installing a CLI version whose major version differs from the currently installed one, and link to the CLI CHANGELOG.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| public/scripts/install_cli.sh | Adds major-version warning, backup-before-overwrite, and --undo restore path. |
| public/scripts/install_cli.py | Adds backup/undo support, major-version warning, and CLI arg wiring for --undo. |
| public/scripts/install_cli.ps1 | Adds major-version warning, backup-before-overwrite, and --undo restore path for Windows. |
Comments suppressed due to low confidence (4)
public/scripts/install_cli.sh:432
- Because this warning is only reached inside the non-
--forcebranch, a user performing a forced install over an existing CLI won’t see the major-version warning. If the warning is meant to apply to any overwrite, consider detecting the currently installed version and callingwarn_major_upgradeeven when--forceis set.
;;
--generic-linux)
GENERIC_LINUX=true
shift
;;
public/scripts/install_cli.ps1:67
- The major-version warning triggers on any difference in major version, including downgrades, but the message always says “major version upgrade”. Consider changing wording to “major version change” or detecting direction so the message is accurate.
function Write-ColorMessage {
param(
[string]$Color,
[string]$Message
)
public/scripts/install_cli.ps1:225
- This major-version warning is inside a
-not $FORCEguard, so a user doing a forced overwrite won’t see the warning. If the warning is meant to apply whenever an existing CLI is being replaced, consider running the version check andTest-MajorVersionUpgradeeven when--forceis specified.
$VERSION = $args[$i + 1]
$i++
public/scripts/install_cli.sh:126
- The warning triggers on any major-version difference, including downgrades (e.g., v2.x.x -> v1.x.x), but the message always says “major version upgrade”. Consider either (a) changing wording to “major version change” or (b) detecting direction and saying “upgrade” vs “downgrade” accordingly.
if command_exists curl; then
retry_command curl -s "$UNIVERSAL_INSTALLER_URL" -o /tmp/install_pkg.sh || die "Failed to download universal installer"
elif command_exists wget; then
retry_command wget -q "$UNIVERSAL_INSTALLER_URL" -O /tmp/install_pkg.sh || die "Failed to download universal installer"
else
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| done | ||
|
|
||
| # Handle undo (no packages or network needed) | ||
| if [ "$UNDO" = true ]; then | ||
| undo_upgrade |
There was a problem hiding this comment.
Same as above: the major-version warning is skipped when --force is used because this check only runs in the FORCE=false path. If you want the warning to always show on overwrite, move the warning logic out of the FORCE=false guard and handle equality checks separately.
| self._write( | ||
| colorize( | ||
| "warning", | ||
| f"WARNING: This is a major version upgrade (v{current_major}.x.x -> v{new_major}.x.x).", | ||
| ) |
There was a problem hiding this comment.
The warning message says “major version upgrade”, but the check only tests inequality of major components, so it will also fire for major downgrades. Consider adjusting wording to “major version change” or computing direction (upgrade vs downgrade) for a more accurate message.
| if current_version: | ||
| self._warn_major_upgrade(current_version, version_to_install) | ||
| self._write(f"Installing {colorize('b', version_to_install)}") |
There was a problem hiding this comment.
--force returns early from get_version() without determining current_version, which means the new major-version warning will never be shown for forced installs. If the warning is intended whenever an existing CLI is being overwritten, consider still probing the current version (best-effort) and calling _warn_major_upgrade even in the --force path.
Add major version upgrade warnings and a
--undooption to the CLI installation scripts.The
--undooption allows users to easily revert to the previous CLI version if an upgrade introduces issues, by backing up the existing binary before an upgrade. The major version warning informs users of potential breaking changes and directs them to the CHANGELOG.