LinuxCommandLibrary

alr

Manage Ada language projects

TLDR

Create a binary or library project

$ alr init [--bin|--lib] [project_name]
copy

Add a dependency to the project
$ alr add [crate]
copy

Run the compiled binary (no need to do build before)
$ alr run
copy

Compile the project
$ alr build [--release|--development|--validation]
copy

SYNOPSIS

alr [global-options] COMMAND [cmd-options] [args]

PARAMETERS

-h, --help
    Print help for command or subcommand

-V, --version
    Display alr version

-v, --verbose [n]
    Set verbosity (0-4; repeatable for higher)

-q, --quiet
    Reduce verbosity by one level

--root[=DIR]
    Explicit crate root directory (default: auto-detect)

--here
    Force current directory as crate root

--no-external-pkg-trees
    Ignore external package trees (use only alire dir)

--no-switch
    Do not auto-switch debug/release profile

--alire-index=URL
    Override catalog index URL

--alire-host=URL
    Override binary host URL

--keep-going
    Continue on non-fatal errors

--jobs[=n]
    Parallel jobs for build (default: auto)

DESCRIPTION

alr is the command-line tool for Alire, a modern package manager and build assistant for Ada and SPARK projects. It streamlines Ada development by automating dependency resolution, project creation, building, testing, and publishing.

Alire manages crates (self-contained Ada libraries or applications) via a central index of indexed releases. It supports multiple Ada toolchains like GNAT Community, GNAT Pro, and others, generating standard GPRbuild project files.

Core workflows:
alr init creates new crates with predefined templates (binary, library, etc.).
alr with or alr get adds dependencies, fetching and configuring them.
alr build compiles with full dependency closure.
alr run, alr test execute binaries/tests.
alr publish shares crates to the index.

Alire ensures reproducibility with locked dependency versions, switchable profiles (debug/release), and integration with CI/CD. It's cross-platform, lightweight, and requires no central registry login for basic use.

CAVEATS

Requires GNAT toolchain (GPRbuild). Not in standard repos; install via curl -sfL https://alire.ada.dev/install.sh | sh or distro packages. Needs internet for index/deps initially. SPARK features require prover tools.

KEY SUBCOMMANDS

init [flags]: New crate
build: Compile
run: Execute binary
with pkg: Add dep
get pkg: Fetch dep
update: Sync deps
test: Run tests
publish: Share crate

QUICK START

alr init --bin myapp
cd myapp
alr with aws # e.g., add AWS
alr build
alr run
See alr help for details.

HISTORY

Alire launched in 2019 by AdaCore/collaborators as AdaCore's answer to Cargo-like tooling. Stable 1.0 in 2020; now v2+ supports SPARK, toolchains, binaries. Actively maintained with community contributions.

SEE ALSO

gprbuild(1), gnat(1), gnatmake(1), git(1)

Copied to clipboard