All Products
Search
Document Center

Alibaba Cloud CLI:macOS

最終更新日:Sep 23, 2024

This topic describes how to install Alibaba Cloud CLI on macOS.

Procedure

You can use one of the following methods to install Alibaba Cloud CLI on macOS.

Install Alibaba Cloud CLI by using a PKG file (recommended)

  1. Download the installation package for macOS.

    • Official website: You can download the latest version of Alibaba Cloud CLI.

    • GitHub: You can download a PKG file of any version of Alibaba Cloud CLI from the GitHub repository based on your business requirements.

  2. Double-click the downloaded installation package and complete the installation as prompted.

Manually install Alibaba Cloud CLI

  1. Download the installation package for macOS.

    Download links:

    • Official website: You can download the latest version of Alibaba Cloud CLI.

    • GitHub: You can download a version of Alibaba Cloud CLI from the GitHub repository based on your business requirements.

  2. In this example, the aliyun-cli-macosx-latest-universal.tgz installation package is downloaded to the $HOME/aliyun directory. Run the following commands to go to the $HOME/aliyun directory and decompress the aliyun-cli-macosx-latest-universal.tgz file to the $HOME/aliyun directory to obtain the aliyun file:

    cd $HOME/aliyun
    tar xzvf aliyun-cli-macosx-latest-universal.tgz
  3. Configure an environment variable.

    Configure an environment variable by moving the file to the specified directory

    Procedure

    Note

    Before you perform this operation, run the echo $PATH command to check whether the /usr/local/bin path exists in the value of the system environment variable PATH. Otherwise, configure an environment variable for the aliyun file based on your business requirements.

    Run the following command to copy the aliyun file to the /usr/local/bin directory:

    sudo cp aliyun /usr/local/bin

    If you are a root user, remove sudo from the command.

    Configure a temporary environment variable by using the export command

    Important

    A temporary environment variable configured by using the export command is valid only for the current session. When you exit the session, the configured environment variable is deleted.

    • Run the following command to configure a temporary PATH environment variable. You need to replace <CLI_PATH> in the command with the directory in which your aliyun file is stored.

      # Replace <CLI_PATH> in the command with the directory in which your aliyun file is stored. 
      export PATH="$PATH:<CLI_PATH>"
    • Check whether the configuration is successful.

      Run the echo $PATH command. If the returned result contains the directory in which the aliyun file is stored, the configuration is successful.

    Configure a permanent environment variable by using a configuration file

    • Run the following commands to configure a permanent PATH environment variable.

      Note

      By default, the latest version of macOS uses the Zsh shell. You can run the echo $SHELL command in the terminal and view the shell type in the result returned.

      • If you use the Bash shell, you need to configure the environment variable in the .bash_profile file. You need to replace <CLI_PATH> in the command with the directory in which your aliyun file is stored.

        # Replace <CLI_PATH> in the command with the directory in which your aliyun file is stored. 
        echo 'export PATH=$PATH:<CLI_PATH>' >> ~/.bash_profile
        # Make the configuration file take effect.
        source ~/.bash_profile
      • If you use the Zsh shell, you need to configure the environment variable in the .zshrc file. You need to replace <CLI_PATH> in the command with the directory in which your aliyun file is stored.

        # Replace <CLI_PATH> in the command with the directory in which your aliyun file is stored. 
        echo 'export PATH=$PATH:<CLI_PATH>' >> ~/.zshrc
        # Make the configuration file take effect.
        source ~/.zshrc
    • Check whether the configuration is successful.

      Run the echo $PATH command. If the returned result contains the directory in which the aliyun file is stored, the configuration is successful.

Install Alibaba Cloud CLI by using Homebrew

Note

Before you install Alibaba Cloud CLI, make sure that you have installed Homebrew on your macOS. If not, visit the official website of Homebrew to install Homebrew.

Run the following command to install Alibaba Cloud CLI:

brew install aliyun-cli

Verify the installation

Run the following command on the terminal to check whether Alibaba Cloud CLI is installed:

aliyun version

If a version number of Alibaba Cloud CLI similar to the following example is returned, Alibaba Cloud CLI is installed.

3.0.16