---
title: "U3012: Host capability in `main` not granted by `una run`"
url: https://una-lang.org/en/docs/errors/U3012/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U3012.md
---

# U3012: Host capability in `main` not granted by `una run`

A `uses` clause of `main` names a host operation that no grant allows.

## Why Una rejects it

Host capabilities enter a program only through the `uses` of `main`, and `una run` grants only the capabilities listed in `--grant` flags or in the package's grants: `[run] grants` in `una.toml`, or from edition `0.4` the `grants` line of the `run` section of `ita.una` (`spec/04 §8`, `spec/05 §7`).

- When the package lists grants, `una check` compares them with the host operations in the `uses` of `main` in the entry module, and reports each `uses` clause with an operation that no grant allows.
- `una run` reports it too, before anything runs, with the package's grants and those of its `--grant` flags together (`spec/13 §5`).

## How to fix it

- Remove the `uses` clause when `main` does not need the operation.
- Otherwise add a grant spec for the capability, such as `"clock"`, to `[run] grants` in `una.toml`, or from edition `0.4` to the `grants` of the `run` section of `ita.una`, or pass it to `una run` as `--grant clock`. The program then gets this host authority when it runs, and the repair is marked as a `grant` widening (ADR 0097).
- For a capability that is not a host capability, no grant provides it: install a handler for it with `with` inside `main`.

## The repair at a glance

`una.toml`

```diff
  [package]
  name = "demo"
  version = "0.1.0"
  edition = "0.1"

  [run]
  entry = "demo"
- grants = ["console"]
+ grants = ["console", "clock"]
```

## Failing example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.1"

[run]
entry = "demo"
grants = ["console"]
```

`src/demo.una`

```una
module demo

pub main() -> Unit
  uses @console: Console[print]
  uses @clock: Clock[now]
=
  let now = @clock.now()
  @console.print("now: {now}")
```

## Fixed example

`una.toml`

```toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.1"

[run]
entry = "demo"
grants = ["console", "clock"]
```

`src/demo.una`

```una
module demo

pub main() -> Unit
  uses @console: Console[print]
  uses @clock: Clock[now]
=
  let now = @clock.now()
  @console.print("now: {now}")
```
