> For AI agents: the complete documentation index is available at https://enclo.nstlopez.com/llms.txt, the full documentation bundle is available at https://enclo.nstlopez.com/llms-full.txt.

# Building from source

On macOS, you can install enclo without building via
[Homebrew](https://enclo.nstlopez.com/guide/quickstart.md#1-install). On Linux, building from source is currently
the only option.

Building requires an Apple silicon Mac or a Linux machine with `/dev/kvm`.
Intel Macs are not supported, and Windows is not supported yet. Run all
commands below from the repository root:

```sh
git clone https://github.com/Nsttt/enclo
cd enclo
```


**Debian and Ubuntu**

For Debian 13 and Ubuntu 24.04. Your user must be able to open `/dev/kvm`; if
not, run `sudo usermod -aG kvm "$USER"` and log in again.
```sh
sudo apt install gcc libc6-dev libclang-dev make pkg-config curl erofs-utils e2fsprogs
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
. "$HOME/.cargo/env"
rustup target add "$(uname -m)-unknown-linux-musl"
scripts/install-libkrun.sh ~/.local/enclo
export LIBKRUN_LIB_DIR=~/.local/enclo/lib64
make install
```
Skip the second and third lines if you already have Rust installed via rustup.
The `export` line applies only to the current shell, and subsequent builds
require it, so add it to your shell profile.


**Fedora and openSUSE**

Both distributions package libkrun, so a single package-manager command
replaces both the `apt` install and the libkrun build script:
```sh
sudo dnf install libkrun-devel erofs-utils e2fsprogs gcc make curl      # Fedora
sudo zypper install libkrun-devel erofs-utils e2fsprogs gcc make curl   # openSUSE
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
. "$HOME/.cargo/env"
rustup target add "$(uname -m)-unknown-linux-musl"
make install
```
Both commands have only been run on arm64 inside containers as root.


**macOS**

With [Homebrew](https://brew.sh) and Rust from [rustup](https://rustup.rs):
```sh
brew install libkrun libkrunfw erofs-utils e2fsprogs
rustup target add aarch64-unknown-linux-musl
make install
```


`make install` builds the guest images, `enclo-shim`, and the `enclo` binary,
then installs them under `ENCLO_HOME` (default `~/.enclo`). It is safe to
re-run, and it prints the `PATH` line to add to your shell startup file. Once
installed, [connect your harness](https://enclo.nstlopez.com/guide/harnesses.md).

Running `make m0` instead of `make install` builds the same components and
boots a single sandbox to verify the boot path, ending with
`PASS: milestone 0 exit test`.

## Linux requirements

- Your user must be able to open `/dev/kvm`, which on most distributions
  means being in the `kvm` group.
- `erofs-utils` must be version 1.7 or newer and built with zlib support.
  Debian 12 and Ubuntu 22.04 ship older versions that must be built from
  source.
- Rust must be installed via rustup so you can add the musl target required by
  the guest agent.

## More

See
[Building enclo from source](https://github.com/Nsttt/enclo/blob/main/docs/building.md)
in the repository for per-distribution notes, running `enclo-shim` directly
with a spec file, release builds, Make targets, cross-architecture testing, and
the repository layout.
