# Installation

Install Lafke and its analysis engine, choose a version, and remove them again.

## Install script

```sh
curl -fsSL https://lafke.sh/install | sh
```

The installer supports macOS and Linux on amd64 and arm64. It downloads the release archive, checks its SHA-256 against the release's `checksums.txt`, verifies its GitHub attestation, installs `lafke`, and then installs the analysis engine.

To install a specific version:

```sh
curl -fsSL https://lafke.sh/install | sh -s -- --version v0.1.0
```

### Options

| Option | Environment variable | What it does |
| --- | --- | --- |
| `--version <tag>` | `VERSION` | Installs this release instead of the latest one. |
| `--skip-attestation` | `SKIP_ATTESTATION=1` | Installs without verifying the GitHub attestation. |
| `--skip-engine` | `SKIP_ENGINE=1` | Leaves out the analysis engine. Install it later with `lafke engine install`. |
| | `INSTALL_DIR` | Installs to this directory. |

### GitHub CLI

Attestation verification needs the [GitHub CLI](https://cli.github.com) (`gh`), signed in with `gh auth login`. Without it, the installer stops. Pass `--skip-attestation` to install without verifying.

### Install location

Lafke is installed to `/usr/local/bin`, or to `~/.local/bin` if `/usr/local/bin` is not writable. Set `INSTALL_DIR` to choose another directory.

### Windows

The installer does not support Windows. Windows builds are published as ZIP archives on the [releases page](https://github.com/lafke/lafke/releases).

## The analysis engine

Two executables work together:

- `lafke`: the command-line interface.
- `lafke-engine`: the source-code analysis engine that `lafke` starts for `sast`, `security`, `chain`, and related commands. It is released separately, from [lafke/engine-releases](https://github.com/lafke/engine-releases).

Commands that do not analyze source code, such as `scan`, `lock`, and `verify`, work without the engine.

The installer runs `lafke engine install` for you. That command downloads the newest engine that speaks this `lafke`'s protocol, checks its SHA-256 and its GitHub attestation, and keeps it in the user cache.

| Command | What it does |
| --- | --- |
| `lafke engine install` | Downloads and installs the engine. An installed version is not downloaded again unless you pass `--force`. |
| `lafke engine update` | Installs the newest compatible engine and removes older ones. |
| `lafke engine list` | Lists the published engine releases that speak this `lafke`'s protocol. |
| `lafke engine status` | Shows which engine `lafke` uses and which are installed. |

Set `LAFKE_ENGINE_VERSION` to pin an engine version. `lafke doctor` reports an engine that is missing or that this `lafke` cannot use.

`lafke` looks for the engine in this order:

1. `LAFKE_ENGINE`
2. the directory of its own executable
3. the engines installed by `lafke engine install`
4. `PATH`

## Uninstall

```sh
lafke uninstall
```

This removes the `lafke` executable, the `lafke-engine` next to it, the engines downloaded by `lafke engine install`, and the response cache. Project files such as `lafke.lock` and `.lafke/` are never touched.

| Flag | What it does |
| --- | --- |
| `--dry-run` | Lists what would be removed and changes nothing. |
| `--yes` | Skips the confirmation prompt. |
| `--keep-cache` | Keeps the on-disk response cache. |

An engine found through `LAFKE_ENGINE` or `PATH` is left alone, because the installer did not put it there. If a package manager installed `lafke`, uninstall it with that package manager instead.
