This topic describes how to update Alibaba Cloud CLI and provides important notes for the process.
Precautions
To avoid version conflicts and potential compatibility issues, always use the same method for updating that you used for the initial installation. For example:
If you installed Alibaba Cloud CLI by using Homebrew, continue to use Homebrew for updates. Do not use an installation package or script to update it.
If you installed Alibaba Cloud CLI in a custom directory on Linux or macOS, we recommend manually updating it with a TGZ file to ensure proper file replacement.
If you used a custom path to install Alibaba Cloud CLI, specify the same path when you update to ensure consistency.
If you encounter any of the following situations, uninstall the CLI completely and then perform a fresh installation:
You are unsure of the original installation method or directory.
You need to switch to an incompatible installation method, such as from a script-based installation to Homebrew.
You need to change the installation directory.
Procedure
In the following steps, <script_path> and <install_path> are placeholders. Replace them with your actual script file path and Alibaba Cloud CLI installation directory before running the commands.
Linux
Update by using a Bash script
Run the following command to install the latest version of Alibaba Cloud CLI.
/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)"Update by using a TGZ file
Download the installation package that suits your system architecture.
NoteRun the
uname -mcommand to check your Linux system architecture. If the output isarm64oraarch64, your system architecture is ARM64. Otherwise, it is AMD64.Run the following command to download the latest installation package for Linux AMD64 systems.
curl https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o aliyun-cli-linux-latest.tgzRun the following command to download the latest installation package for Linux ARM64 systems.
curl https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-arm64.tgz -o aliyun-cli-linux-latest.tgz
Decompress the installation package to the installation directory to overwrite the old files.
tar xzvf aliyun-cli-latest.tgz -C <install_path>
macOS
Update by using a PKG file
Download the latest PKG file for macOS from the following link:
https://aliyuncli.alicdn.com/aliyun-cli-latest.pkg.Double-click the downloaded package and follow the on-screen instructions to complete the update.
Update by using Homebrew
Run the following command to update Alibaba Cloud CLI by using Homebrew.
brew update && brew upgrade aliyun-cli && brew cleanup aliyun-cliUpdate by using a Bash script
Run the following command to install the latest version of Alibaba Cloud CLI.
/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)"Update by using a TGZ package
Run the following command to download the latest installation package for macOS systems.
curl https://aliyuncli.alicdn.com/aliyun-cli-macosx-latest-universal.tgz -o aliyun-cli-macosx-latest-universal.tgzDecompress the installation package to the installation directory to overwrite the old files.
tar xzvf aliyun-cli-macosx-latest-universal.tgz -C <install_path>
Windows
Update by using a ZIP package
Download the latest package for Windows from the following link:
https://aliyuncli.alicdn.com/aliyun-cli-windows-latest-amd64.zip.Decompress the
aliyun.exeexecutable file in the installation package to the installation directory of Alibaba Cloud CLI, overwriting the existing file to complete the update.NoteThis file must be run from a CLI. It will not work if double-clicked.
Update by using a PowerShell script
Create a script file named
Install-CLI-Windows.ps1and save the following code to the file. If you already have this script, skip this step.Run the following command to run the script file to update Alibaba Cloud CLI.
powershell.exe -ExecutionPolicy Bypass -File <script_path> [-InstallDir <install_path>]