We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
MaterialsConsole

Obtaining Command Line Tools

The Command Line Tools package includes codelinter (code check tool), hstack (stack parsing tool), hvigorw (command line build tool), ohpm (third-party dependency management tool), and a series of tools contained in the SDK. This topic describes how to use the codelinter, hstack, hvigorw, and other tools. For details about how to use the tools contained in the SDK, see About This Kit.

Downloading Command Line Tools

Go to Download Center to download the Command Line Tools, and verify the integrity by following the instructions in Tool Integrity.

NOTE

Since the HarmonyOS SDK is embedded in DevEco Studio, there is no need for separate downloads or configurations.

Setting Environment Variables

Decompress the Command Line Tools package. Tools such as codelinter and ohpm are located in the bin directory under command-line-tools. You must add this directory to the PATH environment variable.

Windows

After decompressing the Command Line Tools package, add the ${Command Line Tools decompression path}\command-line-tools\bin directory to the system or user PATH environment variable. Then, open the CLI again.

The figure below shows an example path when the Command Line Tools package is decompressed to the root directory of drive D.

macOS/Linux

  1. Decompress the downloaded command line tool to the local PC.
  2. Start the terminal tool and run the following command:
    echo $SHELL 
    • If the command output is /bin/bash, open the .bash_profile file.
      vi ~/.bash_profile
    • If the command output is /bin/zsh, open the .zshrc file.
      vi ~/.zshrc
  3. Press i to enter Insert mode.
  4. Run the following command to add the decompression path of Command Line Tools to the PATH environment variable. Replace the placeholder with the actual decompression path of Command Line Tools:
    export PATH=${Command Line Tools decompression path}/command-line-tools/bin:$PATH  
  5. Press Esc to exit the edit mode, enter :wq, and press Enter to save the settings.
  6. Run the following command for the environment variable to take effect.
    • If the .bash_profile file is opened in Step 2, run the following command:
      source ~/.bash_profile
    • If the .zshrc file is opened in Step 2, run the following command:
      source ~/.zshrc
NOTE

To verify whether the configuration is successful, run the related commands. For example, run the codelinter -v command to check whether the codelinter tool version can be obtained correctly.