# Install

> Install the kurogane CLI and the tools your apps build with.

The `kurogane` CLI creates, runs and bundles your apps. It also installs the Chromium runtime they need.

## Install the CLI

On Linux and macOS:

```bash
curl --proto '=https' --tlsv1.2 -LsSf https://kurogane-rs.org/install.sh | sh
```

On Windows:

```powershell
powershell -c "irm https://kurogane-rs.org/install.ps1|iex"
```

The installers download the prebuilt CLI for your platform and check its SHA-256 checksum. Then they put it on your `PATH`. They need no administrator rights, no Rust toolchain and no package manager.

### With Nix

On NixOS and other systems with Nix:

```bash
nix profile add github:0x48piraj/kurogane
```

See [Nix and NixOS](#nix-and-nixos) for system flakes and GPU drivers.

### With Cargo

With Rust already installed:

```bash
cargo install kurogane-cli
```

The development version builds from the repository:

```bash
cargo install --git https://github.com/0x48piraj/kurogane kurogane-cli
```

> [!IMPORTANT]
> The development version may be ahead of the latest release and come with a few rough edges.

## What else you need

The CLI is all the installers put on your machine. Building and running apps also needs these:

| Tool | Needed for | Install |
|---|---|---|
| Rust 1.96 or newer | all platforms | [rustup.rs](https://rustup.rs) |
| Visual Studio C++ Build Tools | Windows | Visual Studio Installer, workload **Desktop development with C++** (includes the Windows SDK) |
| Xcode Command Line Tools | macOS | `xcode-select --install` |
| C compiler and Chromium's libraries | Linux | Debian and Ubuntu: `sudo apt install build-essential libnss3 libgtk-3-0 libgbm1 libxkbcommon0 libasound2` (Ubuntu 24.04: `libgtk-3-0t64 libasound2t64`). Fedora: `sudo dnf install gcc nss gtk3 mesa-libgbm libxkbcommon alsa-lib` |
| Node.js | starters with a JavaScript frontend | [nodejs.org](https://nodejs.org) |

`kurogane run`, `dev` and `bundle` install the Chromium runtime when it is missing. `kurogane install` installs it ahead of time.

Check your setup:

```bash
kurogane doctor
```

It checks the Chromium runtime, the platform's build tools and the project in the current directory.

## Try it

Run the showcase to see Kurogane at work:

```bash
kurogane showcase
```

## Supported platforms

| Platform | Architectures | Minimum OS |
|---|---|---|
| Linux (glibc) | x86_64, aarch64 | glibc 2.31 (Ubuntu 20.04, Debian 11) |
| macOS | Apple Silicon, Intel | macOS 12 |
| Windows | x86_64, ARM64 | Windows 10 |
| NixOS, Nix | x86_64-linux, aarch64-linux, aarch64-darwin | |

The Linux CLI is a static binary and starts on any distribution. Apps need glibc because Chromium does. Alpine and other musl systems can install the CLI but can't run apps.

An app needs at least the glibc of the machine that built it. Build Linux bundles on the oldest distribution you support.

## Upgrade

Run the installer again. It replaces the CLI only after the new one has been downloaded, verified and run. An interrupted or failed upgrade keeps the previous version.

## Installer options

`install.sh` takes options after `sh -s --`:

```bash
curl --proto '=https' --tlsv1.2 -LsSf https://kurogane-rs.org/install.sh | sh -s -- --version <version>
```

| `install.sh` | `install.ps1` | Environment | Effect |
|---|---|---|---|
| `--version <v>` | `-Version <v>` | `KUROGANE_VERSION` | installs a specific release instead of the latest |
| `--install-dir <dir>` | `-InstallDir <dir>` | `KUROGANE_INSTALL_DIR` | installs the binary somewhere else |
| | | `KUROGANE_HOME` | keeps the installation in another home than `~/.kurogane` (Unix) |
| `--no-modify-path` | `-NoModifyPath` | `KUROGANE_NO_MODIFY_PATH=1` | leaves shell startup files and the user PATH alone |
| `--force-generic` | | | installs the generic Linux binary on NixOS anyway |
| `-q`, `--quiet` | | | prints only errors and the summary |
| `-y`, `--yes` | | | accepted for compatibility; the installers never prompt |
| | `-Arch <arch>` | `KUROGANE_ARCH` | installs `x86_64` or `aarch64` instead of the detected architecture (Windows) |
| | `-DownloadUrl <url>` | `KUROGANE_DOWNLOAD_URL` | sets a release mirror base URL (https only) |

`irm | iex` can't pass arguments. On Windows set the variables first or run the script as a script block:

```powershell
$env:KUROGANE_VERSION = '<version>'; irm https://kurogane-rs.org/install.ps1 | iex
```

```powershell
& ([scriptblock]::Create((irm https://kurogane-rs.org/install.ps1))) -Version <version>
```

The installers never prompt. They behave the same from a pipe, a terminal or CI. In GitHub Actions they also add the install directory to `$GITHUB_PATH`.

## Where things go

| | Unix | Windows |
|---|---|---|
| CLI | `~/.kurogane/bin/kurogane` | `%LOCALAPPDATA%\kurogane\bin\kurogane.exe` |
| PATH setup | `~/.kurogane/env`, sourced from `~/.profile`, `~/.bashrc`, `~/.bash_profile`, `~/.bash_login` and `~/.zshenv` where they exist; fish `conf.d/kurogane.fish` | user `Path` in `HKCU\Environment` |
| Install receipt | `~/.kurogane/receipt.json` | `%LOCALAPPDATA%\kurogane\receipt.json` |
| Chromium runtime | `~/.local/share/tanso/cef/<version>/` (Linux), `~/Library/Application Support/tanso/cef/<version>/` (macOS) | `%LOCALAPPDATA%\tanso\cef\<version>\` |

The installer creates `~/.profile` when it is missing. It creates `~/.zshenv` too when zsh is installed.

`kurogane self uninstall` reads the receipt to know what it may remove. The Chromium runtime is shared with every project built with [tanso](https://github.com/kurogane-rs/tanso), Kurogane's CEF bindings.

## Verify a release

The installers check every download against the SHA-256 published in the same release. They refuse to install on a mismatch or when no SHA-256 tool is available.

Every release artifact carries a [GitHub artifact attestation](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations). `install.sh` and `install.ps1` carry one too. It proves the release workflow in [kurogane-rs/kurogane-install](https://github.com/kurogane-rs/kurogane-install) built the artifact. Check one with the GitHub CLI:

```bash
gh release download v<version> --repo 0x48piraj/kurogane --pattern 'kurogane-cli-x86_64-unknown-linux-musl.tar.gz'
gh attestation verify kurogane-cli-x86_64-unknown-linux-musl.tar.gz --repo kurogane-rs/kurogane-install
```

Review the installer before you run it:

```bash
curl --proto '=https' --tlsv1.2 -LsSf https://kurogane-rs.org/install.sh -o install.sh
less install.sh
sh install.sh
```

## Nix and NixOS

On NixOS install through the flake. The prebuilt Linux binaries and the Chromium runtime they download expect the usual `/lib` layout. NixOS has none. `install.sh` stops there and prints the Nix command instead.

The flake builds the CLI from source. It includes the Chromium runtime, its libraries and the toolchain. `kurogane dev` works right away.

### In your system flake

Add Kurogane to your flake inputs:

```nix
inputs.kurogane.url = "github:0x48piraj/kurogane";
```

On `nixos-unstable`, follow your system's `nixpkgs` revision:

```nix
inputs.kurogane = {
  url = "github:0x48piraj/kurogane";
  inputs.nixpkgs.follows = "nixpkgs";
};
```

Pass `inputs` to your NixOS modules through `specialArgs` in `nixpkgs.lib.nixosSystem`:

```nix
specialArgs = { inherit inputs; };
```

Install Kurogane from any module:

```nix
{ inputs, pkgs, ... }:
{
  environment.systemPackages = [
    inputs.kurogane.packages.${pkgs.stdenv.hostPlatform.system}.default
  ];
}
```

On a stable NixOS release, change `inputs.nixpkgs.follows` to `"nixpkgs-unstable"` when your flake defines that input. Otherwise leave out the `follows` line and use Kurogane's own nixpkgs revision. Kurogane requires Rust 1.96 which a stable release may not provide. Its own nixpkgs revision may also bring newer GPU drivers than the release channel.

The Home Manager module adds Kurogane to `home.packages`. `nixos-rebuild switch` activates it when Home Manager is part of the NixOS configuration. Standalone Home Manager uses `home-manager switch`.

### With your Nix profile

```bash
nix profile add github:0x48piraj/kurogane                 # latest
nix profile add github:0x48piraj/kurogane/v<version>       # a release
nix run github:0x48piraj/kurogane -- --help               # without installing
```

On `nixos-unstable` add `--override-input nixpkgs nixpkgs`. It builds Kurogane on your registry's nixpkgs which a NixOS system built from a flake points at its own:

```bash
nix profile add github:0x48piraj/kurogane --override-input nixpkgs nixpkgs
```

`nix profile upgrade` drops the override and rebuilds on Kurogane's own nixpkgs. Upgrade by installing again:

```bash
nix profile remove kurogane
nix profile add github:0x48piraj/kurogane --override-input nixpkgs nixpkgs
```

`nix profile` and `nix run` work on other Linux distributions with Nix too.

### GPU drivers on NixOS

The drivers come from your system's nixpkgs. An app built on an older nixpkgs can't load them. Chromium then renders without the GPU and so does any GPU code of your own. On `nixos-unstable`, follow your system's `nixpkgs` input to build Kurogane against the same revision.

An app keeps the C library it was built with. Run `cargo clean` in projects built before you change nixpkgs. `kurogane clean` removes the showcase.

`kurogane doctor` checks OpenGL with the libraries your apps load. The flake brings its own `glxinfo` for that.

## Uninstall

```bash
kurogane self uninstall
```

It removes an installer-managed Kurogane installation with its CLI, PATH setup, Chromium runtimes and caches. It shows what it will remove and asks first. `--yes` skips the question. `--keep-data` keeps the runtimes and caches.

The Chromium runtimes live in tanso's shared installation. Other projects built on tanso use it too. Uninstalling removes all of it.

An installation in another home (`KUROGANE_HOME`) is found from its binary in that home's `bin` folder. Set `KUROGANE_HOME` again to uninstall an installation that used both another home and `--install-dir`.

Kurogane keeps:

* Application profiles in `kurogane/profiles` in the local data directory (`~/.local/share`, `~/Library/Application Support` or `%LOCALAPPDATA%`). They hold your apps' data such as cookies and storage. Uninstalling reports where they are.
* Your shell startup files. Only the installer's own entries go.
* An `--install-dir` and anything else installed there.
* Rust, Node.js, build tools and other system dependencies.

### Installations without a receipt

The receipt defines what Kurogane may remove. A binary the receipt doesn't name stays untouched and the command points you to the manual steps.

Remove such a binary the way you installed it:

```bash
cargo uninstall kurogane-cli
```

```bash
nix profile remove kurogane
```

Kurogane still removes its runtimes and caches in this case.

### Manual uninstall

Remove the installation by hand when `kurogane self uninstall` can't run.

On Linux:

```bash
rm -r ~/.kurogane
rm -r ~/.cache/kurogane ~/.local/share/tanso/cef
```

On macOS remove `~/.kurogane` and these directories:

```text
~/Library/Caches/kurogane
~/Library/Application Support/tanso/cef
```

Then remove the installer's line from your shell startup files. It names your home directory in full:

```bash
. "/home/you/.kurogane/env"
```

Fish users remove `~/.config/fish/conf.d/kurogane.fish`.

On Windows remove everything under `%LOCALAPPDATA%\kurogane` except `profiles`. Remove the Chromium runtimes in `%LOCALAPPDATA%\tanso\cef` too. Then remove `%LOCALAPPDATA%\kurogane\bin` from your user `Path` in **Edit environment variables for your account**.
