> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blobhub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Installer overview

> Install an app, upgrade it, uninstall it and read its log from a terminal or CI

The `installer` command group works on an installer blob: the blob that holds an organization's installations of apps.
It installs a committed version of an app under an alias, upgrades it to a newer version, uninstalls it, removes its
record, lists what is installed and reads the log of what happened. What an installation, a status and the log are is
defined by the [installer blob type](https://docs.blobhub.io/blob-types/installer/overview.md); this group is the terminal's way to ask for them.

The examples use the fictional Field Reports app, `acme-corp/field-reports`, installed by the installer
`acme-corp/installed-apps` as `reports`.

## The commands

```bash theme={null}
blobhub installer install   <org>/<app> --installer <org>/<blob> --alias <alias> [--version <v>]
                            [--input <name=value>] [--yes]
blobhub installer uninstall <alias> --installer <org>/<blob> [--yes]
blobhub installer remove    <alias> --installer <org>/<blob> [--yes]
blobhub installer ls        --installer <org>/<blob>
blobhub installer log       <alias> --installer <org>/<blob> [--follow]
```

| Command | What it does | Network | Writes |
| - | - | - | - |
| [`install`](https://docs.blobhub.io/cli/installer/commands/install) | Installs an app version, or upgrades an installation to a newer version. | Write | An installation |
| [`uninstall`](https://docs.blobhub.io/cli/installer/commands/uninstall) | Deletes the installation's blobs and accounts; keeps its record and log. | Write | The installation |
| [`remove`](https://docs.blobhub.io/cli/installer/commands/remove) | Deletes an uninstalled installation's record and its log. | Write | The installer's records |
| [`ls`](https://docs.blobhub.io/cli/installer/commands/ls) | Lists the installations and whether a newer version exists. | Read | Nothing |
| [`log`](https://docs.blobhub.io/cli/installer/commands/log) | Prints an installation's log, optionally following it. | Read | Nothing |

An installation is made and changed only by `install`, `uninstall` and `remove`; the other two read.

## Plan first, then confirm

Every command that changes an installation shows what it would do before it does it. `install` asks the platform for
its [plan](https://docs.blobhub.io/blob-types/installer/operations/plan.md) first: the lines it would act on, the limits the version needs, the
problems that would stop it, and a [digest](https://docs.blobhub.io/blob-types/installer/operations/plan.md#digest) of what it would act on.
`uninstall` and `remove` send their call once without confirmation, and the platform answers with the lines it would act
on and their digest. The CLI never prompts. It prints the lines, and without `--yes` it refuses:

```mermaid theme={null}
sequenceDiagram
  participant U as Admin
  participant C as blobhub installer install
  participant I as Installer blob
  U->>C: install acme-corp/field-reports --alias reports
  C->>I: read the installer, absent: create it
  C->>I: plan
  I-->>C: lines, limits, problems, digest
  C-->>U: the header, the lines and the limits block
  alt no --yes, or the plan has problems
    C-->>U: refused: pass --yes to install, or each problem (exit 1)
  else --yes, and the plan has changed by the install
    C->>I: install, confirmed: the digest
    I-->>C: plan_changed, with the new plan
    C-->>U: the new plan, then refused (exit 1)
  else --yes, and the same plan
    C->>I: install, confirmed: the digest
    loop each second while installing
      C->>I: read the log and the installation
    end
    C-->>U: the log, ending ready
  end
```

The first run of the Field Reports install, without `--yes`, is the dry run. It prints what `--yes` would do and writes
nothing to the installation:

```bash theme={null}
blobhub installer install acme-corp/field-reports --installer acme-corp/installed-apps --alias reports \
  --version 0.2.0 --input config=@envs/acme.yaml --input weather_key=env:WEATHER_API_KEY
```

```text theme={null}
Field Reports 0.2.0 from acme-corp/field-reports, as reports in acme-corp/installed-apps
  creates blob reports-flows (blobhub.compute.workflow)
  creates blob reports-schedules (blobhub.compute.scheduler)
  creates service account reports-runner, a member of both blobs with WRITE
  stores credentials weather, blobhub and sync_token on reports-runner
  widget report-viewer asks to: read session objects, read threads
  runs reports-migrate in session reports
# … the limits block: rows at acme-corp, acme-corp/installed-apps and both blobs, every one ok
refused: pass --yes to install
```

The header names the app's label and version, the app, the alias and the installer; an upgrade adds the version it
leaves, as `(from 0.2.0)`, and a draft reads `draft 0.3.0`. A label or version that is not text, as a draft's `app.yaml`
may give one, reads as missing, and the plan's problems say why: a version is left out, as
`Field Reports draft from acme-corp/field-reports, as reports-dev in acme-corp/installed-apps`, and a label reads as the
app blob, `acme-corp/field-reports`. The lines under it are the platform's, word for word. The limits block follows
them, cut in this sample: every limit the version needs, grouped under `limits at <where>`, each row `ok` or `unmet`
with what it needs and what the place has ([Limits and problems](https://docs.blobhub.io/cli/installer/commands/install.md#limits-and-problems)
shows a whole one). All of it goes to stderr, so `-q` does not quiet it. The last line is the exact text
`refused: pass --yes to <verb>`, and the exit code is `1`. Under `--json` stdout stays empty and the refusal is one JSON
document on stderr. Its code is `APP_NOT_CONFIRMED`, and `confirm` holds one entry: for `install`, the installation, the
plan's lines and limits, whether the run `created` the installer blob, and the plan's digest; for `uninstall` and
`remove`, the installation, its lines and their digest. A digest is in the entry only when the answer has one.

Run the same command with `--yes` to act. Nothing is carried over from the dry run: the `--yes` run asks again for what
it would do, prints it the same way, and in the same run sends its
[digest](https://docs.blobhub.io/blob-types/installer/operations/plan.md#digest) as `confirmed`. It confirms what it prints then, so with
`--version` left out, a version committed since the dry run is the one it installs; name `--version` where the version
must not move. The digest covers only the gap between that print and the call: the platform plans again before it acts,
and when that plan differs, because a version was committed, an input or a limit's value changed, or another operation
ran, nothing is done. The CLI prints the new plan the platform answers with, and ends with
`refused: the plan changed while it was confirmed; nothing was installed` (`uninstalled`, or `removed`), exit `1`, code
`PLAN_CHANGED`.

A plan that reports problems is never acted on. The CLI checks problems before `--yes`, so `INSTALL_HAS_PROBLEMS` wins
even without it: the CLI prints each as `problem: <text>` on stdout, wrapped at 110 columns, and ends with
`refused: N problems; nothing was installed`, exit `1`. `--yes` overrides nothing: a plan with a problem has no digest,
so there is nothing to confirm.

The CLI reads every field of an answer it would act on before it prints any of it. A plan, or with `--yes` the lines an
`uninstall` or `remove` would confirm, with a field missing or of another shape is refused `API_TRANSIENT_ERROR`,
`cannot read the platform's answer: ...; nothing was installed` (`uninstalled`, or `removed`), and no confirmed call
is sent. A platform refusal ends the run either way, so a field of another shape in one is read as absent and never
printed.

One write happens even without `--yes`: if the installer blob named by `--installer` does not exist, the CLI creates it,
private, and prints `created installer blob acme-corp/installed-apps` before it plans, because a plan is asked of a
revision. A second run finds it.

## Following an operation

An install or an uninstall with `--yes` is asynchronous on the platform: the request answers `installing` or
`uninstalling` and a worker does the rest. The CLI follows the [log](https://docs.blobhub.io/blob-types/installer/overview.md#the-log) once a
second, printing each message as it is written, and drains it once more when the installation leaves that status:

```text theme={null}
14:20:03  install 0.2.0 requested by Ana Ruiz
14:20:03  creates blob reports-flows (blobhub.compute.workflow)
14:20:03  creates blob reports-schedules (blobhub.compute.scheduler)
14:20:03  creates service account reports-runner, a member of both blobs with WRITE
14:20:03  stores credentials weather, blobhub and sync_token on reports-runner
14:20:03  widget report-viewer asks to: read session objects, read threads
14:20:03  runs reports-migrate in session reports
14:20:04  created service account reports-runner
14:20:04  stored 3 credentials on reports-runner
14:20:05  created blob reports-flows; applied 4 definitions, 1 session, 2 objects
14:20:06  created blob reports-schedules; applied 1 schedule
14:20:06  running reports-migrate in session reports
14:20:10  reports-migrate completed in 4.1 s
14:20:10  ready at 0.2.0
```

A line is `HH:MM:SS  message` in local time, with the level before the message when it is not `info`. The command
exits `0` when the installation ends `ready` (or `uninstalled`). It exits `1` with `INSTALLATION_FAILED` when it ends
`failed`, the reason being in the log, and an install that failed is run again with the same command. It gives up after
30 minutes with `INSTALLATION_FOLLOW_TIMEOUT`, and the installation carries on without it; the hint names
`blobhub installer log <alias> --installer <org>/<blob> --follow`, which picks the log up again.

Under `--json`, a failed install or uninstall puts the log's error entries in `problems`, or its last five entries when
none is an error; a timeout puts its last five.

## `--input`

`install` takes an input's value from where you name it. `--input` is repeatable, and each form says where the value is
read from; none of them is a template.

| Form | The value is |
| - | - |
| `--input name=value` | The text after `=`. |
| `--input name=@path` | The file at `path`: a `.json`, `.yaml` or `.yml` file as a document, any other file as text. |
| `--input name=env:VAR` | The environment variable `VAR`. |

A secret input such as `weather_key` is given as `env:` so it never appears in a command line or a shell history. An
unset or empty variable is `ENV_VAR_NOT_SET`, naming the variable; a name given twice, an empty name, a missing `=`, an
`env:` naming no variable, an unreadable file or a document that does not parse is `INPUT_ARGUMENT_INVALID`. The CLI
never prints an input's value, in text or in `--json`. What the inputs are, and how a document is checked against its
schema, is in [`app.yaml`](https://docs.blobhub.io/blob-types/app/app-yaml#inputs).

An input holding a value JSON cannot carry is `VALUE_NOT_JSON`, refused before any request, the installer blob's
creation included. The message names the value by its path and never carries it:

* **A YAML document that holds itself**, an alias inside its own anchor, is refused as the file is read, naming the
  file and the path of what holds itself: `--input config: envs/acme.yaml: regions: holds itself`. An alias outside
  its own anchor is sent as a copy of what the anchor holds.
* **A lone surrogate** in a string or a key, from a document's `\uXXXX` escape of one or an argument or variable whose
  bytes are not UTF-8, is refused in the platform's words, naming its path:
  `inputs.config.city: a lone surrogate is not valid UTF-8`. A key that holds one is written escaped in the path, as
  the [plan](https://docs.blobhub.io/blob-types/installer/operations/plan.md#errors) writes it. A surrogate pair, in JSON or YAML, such as
  `"\ud83d\ude00"`, is one character, and is sent as that character.
* **NaN or an infinity**, such as YAML's `.nan` (`inputs.config.ratio: is not a finite number`), a non-string key,
  such as a number, a value of no JSON type, such as a YAML `!!set` or `!!binary`, and an integer too large to write
  are refused by their path too.

A YAML `!!omap` or `!!pairs` is sent as JSON sends it, an array of `[key, value]` arrays, so a path names an entry by
its index: `inputs.<name>.<key>[0][1]` is the value of its first entry.

On an upgrade, give only what changes: the installation remembers its documents, and a secret whose credentials exist
counts as given.

## Who installs

Installing creates the app's service accounts and stores its credentials, and both need a person behind the request
([Access](https://docs.blobhub.io/blob-types/installer/overview.md#access)). So the first install, and any upgrade that adds an account or a
credential, runs under a person's key, with ADMIN on the installer blob and on its organization. An upgrade that adds
neither can run in CI under a service account's key, with no new account or credential:

```bash theme={null}
BLOBHUB_API_KEY=<service-account-key> blobhub installer install acme-corp/field-reports \
  --installer acme-corp/installed-apps --alias reports --version 0.3.0 --input config=@envs/acme.yaml --yes
```

A service account's key on an install that makes an account or writes a credential is the plan's problem
`person_required`, and nothing is written. The first install of Field Reports, run that way:

```text theme={null}
# … the header, the lines and the limits block
problem: person_required: this install makes service account reports-runner and its credentials, which only a
  person may do; this request comes from a service account's key
refused: 1 problem; nothing was installed
```

An upgrade that writes credentials on an account that exists names them instead,
`this install stores credentials weather and blobhub on reports-runner`, and a caller that is neither a person nor a
service account reads `this request does not come from a person`
([Problems](https://docs.blobhub.io/blob-types/installer/operations/plan.md#problems)).

An app a person may not see, or that does not exist, is the platform's 403, which the CLI reports as
`BLOB_NOT_ACCESSIBLE`. So is an uninstall that retires an account, sent with a service account's key. The CLI names no
cause of its own: the message is what was refused, such as
`cannot install acme-corp/field-reports into acme-corp/installed-apps: ` or
`cannot uninstall in acme-corp/installed-apps: `, then the platform's own message, or
`the platform refused (HTTP 403) without a message` when it gives none. A private app is shared by adding the person,
or the service account, as a member of the app blob with READ.

## Options shared by the group

| Flag | Applies to | Description |
| - | - | - |
| `--installer <org>/<blob>` | Every command | The installer blob, as `<org>/<blob>`. |
| `--yes` | `install`, `uninstall`, `remove` | Confirms the lines the command printed, by sending their digest. |
| `--json` | Every command | One JSON document: the result on stdout, or a refusal on stderr with stdout empty; see [Configuration](https://docs.blobhub.io/cli/configuration.md#output-streams). |

## See also

* [Installer blob type](https://docs.blobhub.io/blob-types/installer/overview.md) —
  [installations](https://docs.blobhub.io/blob-types/installer/overview.md#installations),
  [the log](https://docs.blobhub.io/blob-types/installer/overview.md#the-log), [access](https://docs.blobhub.io/blob-types/installer/overview.md#access) and
  [refusals](https://docs.blobhub.io/blob-types/installer/overview.md#refusals).
* [`plan`](https://docs.blobhub.io/blob-types/installer/operations/plan) and [`install`](https://docs.blobhub.io/blob-types/installer/operations/install) — the
  operations behind `install`.
* [Apps](https://docs.blobhub.io/general/apps.md) — what an app is and its lifecycle: install, upgrade, uninstall and remove.
* [`blobhub app push`](https://docs.blobhub.io/cli/app/commands/push) — installs a draft as a development installation.
* [Error codes](https://docs.blobhub.io/cli/error-codes.md) — every code these commands can raise.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.