# Install the Tern plugin

The plugin is in preview for macOS on Apple Silicon. One release directory holds everything: the plugin, its broker
and worker, an Elide runtime and the embedded SDK the notebook uses. Installing takes one checksum, one unpack and
one script.

## Requirements

| Requirement | Notes |
| --- | --- |
| macOS on Apple Silicon | The installer stops on any other platform. |
| Tern with the `tern` command on `PATH` | The preview is tested with Tern 0.9.12. |
| Elide 1.6.3 or newer on `PATH` | Only for commands you type in a Tern terminal. The plugin's own views use the runtime in the release. |

## Download and install

Download `elide-tern-0.1.0-preview.1-macos-arm64.tar.gz` and `SHA256SUMS` from the
[preview release](https://github.com/elide-dev/tern/releases), then check and unpack them:

```bash
shasum -a 256 -c SHA256SUMS
tar -xzf elide-tern-0.1.0-preview.1-macos-arm64.tar.gz
```

Move `elide-tern-0.1.0-preview.1-macos-arm64` to a permanent location and run the installer from inside it:

```bash
cd elide-tern-0.1.0-preview.1-macos-arm64
sh ./install.sh
```

The installer:

1. Stops unless the machine is macOS on Apple Silicon and `tern` is on `PATH`.
2. Stops with `Incomplete release` when the broker, worker, runtime, SDK or plugin is missing.
3. Writes `plugin/config.json` pointing at the bundled SDK, broker and runtime, unless the file exists.
4. Registers the plugin with `tern plugin link <release>/plugin`.

Tern links to the release directory instead of copying it, so keep the directory in place.

## First launch

Run `tern` in a directory containing `elide.pkl`, or any directory below one:

```bash
cd my-project
tern
```

Open the command palette and choose **Open project workspace**. The workspace opens Files, an editor on `elide.pkl`, a
terminal in the project root and the project toolbar; see [Project workspace](/docs/tern-workspace). **Open REPL** works
without a project.

## Check the install

| Check | Expected |
| --- | --- |
| Status bar in a project terminal | The project's name and **Workspace**. |
| `runtime/bin/elide tern --help` in the release directory | Lists `debug`, `project` and `repl`. |
| `elide tern --help` in a Tern terminal | The same list: the `elide` on `PATH` draws Tern views. |
| `elide test` in a Tern terminal | Results drawn inline in the pane, not printed lines. |

When a check fails, see [Troubleshooting](/docs/tern-troubleshooting).

## Update or remove

| Task | Command |
| --- | --- |
| Update | Unpack the new release in a separate directory and run its `install.sh`. Keep the old directory until its sessions close. |
| Remove | `tern plugin unlink elide` |
| Reset configuration | Delete `plugin/config.json` in the release directory and rerun `install.sh`. |

## Next

Type `elide test` in a Tern terminal and watch the results draw in the pane, then take the tour of the
[Tern plugin](/docs/tern#the-tour).
