Skip to content

Installing AST Metrics

AST Metrics is built in Golang and distributed as a single binary. It has no dependencies.

🚀 Quick Install

Choose your preferred method below.

🪄 Automatic Install (Linux/MacOS/Windows)

Run the following command to download the latest version:

curl -s https://raw.githubusercontent.com/Halleck45/ast-metrics/main/scripts/download.sh|sh

Then move the ./ast-metrics binary to a directory in your PATH (e.g. /usr/local/bin for Linux/MacOS).

Be careful when running scripts from the internet. Always check the content of the script before running it.

Linux (Manual)

Download the binary for your platform (run uname -m in your terminal to get your architecture):

  • amd64 (most common)
  • arm64 (for Raspberry Pi)
  • i386 (for old 32-bit systems)
MacOS (Manual)

Download the binary for your platform (run uname -m in your terminal to get your architecture):

  • arm64 (for Apple Silicon / M1 / M2)
  • amd64 (for Intel Macs)
Windows (Manual)

Download the executable for your platform:

🐘 PHP Project (Composer)

If you are working on a PHP project, you can install AST Metrics as a dev dependency via Composer. This is the recommended way for PHP developers as it manages the binary version for you.

composer require --dev halleck45/ast-metrics

Then you can run it using:

php vendor/bin/ast-metrics analyze .
Go Install

If you have Go installed:

go install github.com/halleck45/ast-metrics@latest

Verify Installation

Verify that the installation worked by opening a new terminal session and listing AST Metrics's available subcommands.

ast-metrics --help

You should see the help message with the available subcommands.

Troubleshooting

If you get an error that the command ast-metrics is not found, you may need to add the directory where the binary is located to your PATH.

Updating

Update is really easy. Just run:

ast-metrics self-update