Use Alire to install gnat / gprbuild?

Hello. I’m just getting started with Ada programming and I’m currently trying to set up a development environment.

Under Debian GNU/Linux 12, I installed FSF GNAT with apt install gnat as described on GetAdaNow.com. However, later I found out about Alire and the alr toolchain command. It seems that Alire can handle different compiler version installations, which I find interesting.

Again, I’m completely new to Ada programming and I have no idea about the tools yet. What is the recommended way to install the compiler and the project manager, should I use Alire or the packages from APT?

Thanks in advance.

Welcome to the Ada community.

Both approaches are fine and are compatible. If you install the Debian package, it will be detected by Alire and used if compatible with the crate you’re compiling. For learning, you can start by any of the two paths. At some point, using Alire will make your life easier, but only if you want to use some libraries, for pure Ada development on top of the standard library, installing gnat and gprbuild packages is enough.

1 Like

If you end up checking out alire there is a pretty good tutorial. Alire will install all of its toolchains to its own location to keep them separate from your os defaults.

See below for how toolchains are setup:

1 Like

Thank you! :grinning:

I see. At this time, I have the following.

marcus@debian:~/Dev/ada-examples$ alr toolchain
CRATE         VERSION  STATUS    NOTES                               
gprbuild      18.0.0   Available Detected at /usr/bin/gprbuild       
gprbuild      22.0.1   Default                                       
gprbuild      2023.0.0 Available Provided by system package: gprbuild
gnat_native   14.1.3   Default                                       
gnat_external 12.2.0   Available Detected at /usr/bin/gnat           

Until I understand the tools better, I would prefer not to install / modify system packages. I work with Rust and Python and I’m used to some kind of virtual environment / package manager.

Can I safely uninstall the crates that I have installed with APT and just have the crates installed by Alire?

Thanks for the link to the Alire docs!

Yes, you can safely uninstall the system packages and leave the versions installed by Alire. Keeping them will also be safe, because you can select the version you want to use as default using alr toolchain --select.

2 Likes