2022-02-07 11:51:12 +01:00
+++
title = "Compiling Garage from source"
weight = 10
+++
2021-05-31 17:13:36 +02:00
2022-02-16 12:18:24 +01:00
Garage is a standard Rust project. First, you need `rust` and `cargo` . For instance on Debian:
2021-05-31 17:13:36 +02:00
```bash
sudo apt-get update
sudo apt-get install -y rustc cargo
```
You can also use [Rustup ](https://rustup.rs/ ) to setup a Rust toolchain easily.
2022-02-16 12:18:24 +01:00
In addition, you will need a full C toolchain. On Debian-based distributions, it can be installed as follows:
```bash
sudo apt-get update
sudo apt-get install build-essential
```
2026-01-13 20:35:56 -08:00
## Building from source from the Forgejo repository
2022-09-06 17:16:45 +02:00
The primary location for Garage's source code is the
2026-01-13 20:35:56 -08:00
[Forgejo repository ](https://git.deuxfleurs.fr/Deuxfleurs/garage ),
2022-09-15 13:23:57 +02:00
which contains all of the released versions as well as the code
2026-01-27 17:08:43 +01:00
for the development of the next version.
2022-09-06 17:16:45 +02:00
2022-09-15 13:23:57 +02:00
Clone the repository and enter it as follows:
2022-09-06 17:16:45 +02:00
```bash
git clone https://git.deuxfleurs.fr/Deuxfleurs/garage.git
cd garage
```
2022-09-15 13:23:57 +02:00
If you wish to build a specific version of Garage, check out the corresponding tag. For instance:
2022-09-06 17:16:45 +02:00
2022-09-15 13:23:57 +02:00
```bash
git tag # List available tags
git checkout v0.8.0 # Change v0.8.0 with the version you wish to build
```
2022-09-06 17:16:45 +02:00
2026-01-27 17:08:43 +01:00
Otherwise you will be building a development build from the `main` branch
2022-09-15 13:23:57 +02:00
that includes all of the changes to be released in the next version.
Be careful that such a build might be unstable or contain bugs,
and could be incompatible with nodes that run stable versions of Garage.
2021-05-31 17:13:36 +02:00
2022-09-15 13:23:57 +02:00
Finally, build Garage with the following command:
2021-05-31 17:13:36 +02:00
```bash
2022-09-15 13:23:57 +02:00
cargo build --release
2021-05-31 17:13:36 +02:00
```
2022-09-15 13:23:57 +02:00
The binary built this way can now be found in `target/release/garage` .
You may simply copy this binary to somewhere in your `$PATH` in order to
have the `garage` command available in your shell, for instance:
2021-05-31 17:13:36 +02:00
```bash
2022-09-15 13:23:57 +02:00
sudo cp target/release/garage /usr/local/bin/garage
2021-05-31 17:13:36 +02:00
```
2022-09-15 13:23:57 +02:00
If you are planning to develop Garage,
you might be interested in producing debug builds, which compile faster but run slower:
this can be done by removing the `--release` flag, and the resulting build can then
be found in `target/debug/garage` .
2021-05-31 17:13:36 +02:00
2022-09-15 13:23:57 +02:00
## List of available Cargo feature flags
2021-05-31 17:13:36 +02:00
2022-09-15 13:23:57 +02:00
Garage supports a number of compilation options in the form of Cargo feature flags,
2022-09-06 17:16:45 +02:00
which can be used to provide builds adapted to your system and your use case.
2022-09-15 13:23:57 +02:00
To produce a build with a given set of features, invoke the `cargo build` command
as follows:
```bash
# This will build the default feature set plus feature1, feature2 and feature3
cargo build --release --features feature1,feature2,feature3
# This will build ONLY feature1, feature2 and feature3
cargo build --release --no-default-features \
--features feature1,feature2,feature3
```
The following feature flags are available in v0.8.0:
| Feature flag | Enabled | Description |
| ------------ | ------- | ----------- |
| `bundled-libs` | * by default * | Use bundled version of sqlite3, zstd, lmdb and libsodium |
2026-01-13 22:42:43 -08:00
| `consul-discovery` | optional | Enable automatic registration and discovery<br>of cluster nodes through the Consul API |
| `fjall` | experimental | Enable using Fjall to store Garage's metadata |
| `journald` | optional | Enable logging to systemd-journald with<br>`GARAGE_LOG_TO_JOURNALD=true` environment variable set |
2022-09-15 13:23:57 +02:00
| `k2v` | optional | Enable the experimental K2V API (if used, all nodes on your<br>Garage cluster must have it enabled as well) |
| `kubernetes-discovery` | optional | Enable automatic registration and discovery<br>of cluster nodes through the Kubernetes API |
2024-03-08 14:11:02 +01:00
| `lmdb` | * by default * | Enable using LMDB to store Garage's metadata |
2026-01-13 22:21:38 -08:00
| `metrics` | * by default * | Enable collection of metrics in Prometheus format on the admin API |
2024-03-14 16:35:15 +01:00
| `sqlite` | * by default * | Enable using Sqlite3 to store Garage's metadata |
2026-01-13 22:42:43 -08:00
| `syslog` | optional | Enable logging to Syslog with<br>`GARAGE_LOG_TO_SYSLOG=true` environment variable set |
2026-01-13 22:21:38 -08:00
| `system-libs` | optional | Use system version of sqlite3, zstd, lmdb and libsodium<br>if available (exclusive with `bundled-libs` , build using<br>`cargo build --no-default-features --features system-libs` ) |
| `telemetry-otlp` | optional | Enable collection of execution traces using OpenTelemetry |