# Package installation

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> Packages are the software a workstation's operating system image doesn't carry, from its package manager, npm, PyPI, Go or mise.


Packages are the software a workstation's operating system image doesn't carry, from its
package manager, npm, PyPI, Go or mise. You list them in a workstation or a
[configuration layer](https://docs-stg.ringleader.dev/workstations/configuration/configuration-layers/).
Ringleader installs them and keeps them at a version you allow. It removes the npm, PyPI,
Go and mise packages you take out. Each install happens in a setup run, one
[configuration pass](https://docs-stg.ringleader.dev/workstations/configuration/step-failures-retries/) of the workstation.

## Package version selection

For `npm`, `pypi` and `go` packages, Ringleader reads the registry and chooses the version
itself, and mise chooses its own under the same rules. The steps are:

1. It keeps the versions your `version` allows. A pre-release is skipped unless `version`
   names one, and a yanked PyPI release is skipped unless `version` is exact.
2. It skips every version published in the last 24 hours. The 24 hours is fixed. An exact
   `version` is exempt, so a release you name by number installs at once.
3. It installs the newest version left. If none is left, the setup step fails and names the
   constraint and the age, and any installed version stays.

For npm and PyPI packages, the 24 hours also applies to every dependency, so a release
that reaches the workstation through a dependency waits too. An exact npm `version` is the
exception: its dependencies are not held back. A Go program's dependencies come from its
own `go.mod`, so `go install` takes no newer ones.

An npm dist-tag other than `latest`, such as `next`, selects that channel. Ringleader
treats the tag as the exact version it names when the tag is read, a pre-release
included, so the 24 hours doesn't apply. The tag `latest` means no constraint.

Ringleader reads a registry only when it must install a package or look for an update. A
setup run that finds the package installed at an allowed version sends no request.

## Package update policies

A package's `updatePolicy` says when an installed package moves to a newer version:

| Value | First install | Later setup runs |
|---|---|---|
| `ensure` (the default) | The newest allowed version | Keeps the installed version. If the package goes missing, installs the version it had again. |
| `pinned` | With an exact `version`, that version. With a range, the same as `ensure`. | Keeps the installed version. If the package goes missing, installs the version it had again. |
| `latest` | The newest allowed version | Keeps the installed version, except that about once a day it moves to the newest allowed version. If the package goes missing, installs the version it had again, or on that daily pass the newest allowed version when it is newer. |

For a system package, `latest` upgrades the package about once a day, and the other two
values leave it installed. A `version` on a system package applies when the package is first
installed. With
[security updates](https://docs-stg.ringleader.dev/workstations/packages-tools-settings/security-updates/) on, a system
package without a `version` also moves to a security fix, whatever its `updatePolicy`.
Security updates skip a system package you declare with a `version`.

These rules apply to every language type:

- An exact `version` never moves, whatever the policy.
- `latest` stays within `version`. An entry with `version: "3"` and `updatePolicy: latest`
  follows the 3.x releases and never moves to 4.
- A missing package comes back at the version Ringleader installed only while that version
  can still be installed. Ringleader installs the newest allowed version instead in these
  cases:
  - The registry no longer lists the old version, has yanked it (PyPI) or has retracted it
    (Go).
  - The install command itself failed for that version.
  - For npm and PyPI, the old version is newer than the 24-hour age limit allows.

  The newest allowed version can be older than the one that went missing. Some entries come
  back at the version the registry or mise names now. That happens when `version` is an npm
  dist-tag such as `next`, mise's `lts`, or a mise request containing `:`.
- Otherwise, Ringleader never moves a package to an older version on its own. A package
  installed at a version newer than `version` allows stays where it is until you change
  the entry.

An npm package installed before these package rules reached the workstation keeps its
version, `latest` included, until you change its entry.

## Package directories and commands

Each package installs into its own directory under `/opt/ringleader/packages/`, owned by
root and readable by everyone. Ringleader links the package's commands into
`/usr/local/bin`, which is on the PATH of every shell, a command run directly over SSH
included. A `mise` command links to mise's own shim, so a project's `mise.toml` can still
choose another version inside that project.

A new version installs beside the old one, and the commands switch once it is ready. A
failed or interrupted install leaves the working version linked. Ringleader removes the
old version after no process runs from it and 24 hours have passed.

Ringleader doesn't overwrite a command it didn't install:

- A command that `/usr/bin`, `/bin`, `/usr/sbin` or `/sbin` already provides fails the
  step. `/usr/local/bin` comes first on the PATH, so the link would replace it.
  To allow it, [let the package replace the command](#let-a-package-replace-a-system-command).
- A command that another package owns, or a file in `/usr/local/bin` that Ringleader didn't
  write, fails the step. The message names both packages, and the file stays as it was.

A package gets its own directory and its own copy of its dependencies. So a tool can't
load a plugin that you declare as a separate entry. `npm ls -g` doesn't list a package
installed this way. `rl troubleshoot <workstation> --report-only` prints the installed
version of every package.

npm packages keep the workstation's default for install scripts. Where the workstation's
npm accepts `--allow-scripts`, `allowScripts` passes your list to it, or lets every script
run when it is `true`. An npm without that option runs install scripts as it always has.

## Package removal

When an `npm`, `pypi`, `go` or `mise` entry leaves the configuration, Ringleader removes
its commands and its directories on the next setup run. A removal that fails is tried
again on the next run.

<div class="callout callout-warning">
  <p class="callout-title">Packages disappear with their layer</p>
  <div class="callout-body">
    A layer can stop applying to a workstation, such as when its author loses access to it.
Ringleader then removes the commands and directories of that layer&rsquo;s packages in the same
way.
  </div>
</div>


Ringleader doesn't remove these:

- System packages.
- An npm package that was installed before these package rules reached the workstation.
- A tool you installed yourself, including a file in `/usr/local/share/mise`.

For a `mise` entry, Ringleader also uninstalls the versions it installed, unless another
mise configuration on the workstation still selects that version.

## Language toolchains

Each language type needs a toolchain. When a configuration declares a package of a type
and the workstation lacks that type's command, Ringleader adds the matching
[devtool](https://docs-stg.ringleader.dev/reference/tools/devtools/):

| Type | Devtool added | What the workstation gets |
|---|---|---|
| `npm` | [`nodejs`](https://docs-stg.ringleader.dev/reference/tools/devtools/nodejs/) | Node.js 24 on Debian and Ubuntu, and the distribution's Node.js on Alpine. A workstation with `node` but no `npm` gets the distribution's `npm` package. |
| `pypi` | [`uv`](https://docs-stg.ringleader.dev/reference/tools/devtools/uv/) | uv, and Python 3.14 for it to build tools on. |
| `go` | [`go`](https://docs-stg.ringleader.dev/reference/tools/devtools/go/) | A Go release from go.dev on Debian and Ubuntu, and the distribution's Go on Alpine. |
| `mise` | [`mise`](https://docs-stg.ringleader.dev/reference/tools/devtools/mise/) | mise. |

A devtool you declare always wins. Ringleader never moves a toolchain the workstation
already has. Two workstations with one configuration can therefore run different Node.js
majors until the configuration declares `nodejs`.

<div class="callout callout-tip">
  <p class="callout-title">Choose the Node.js version</p>
  <div class="callout-body">
    To run packages on Node.js 22, declare <code>nodejs</code> with <code>version: &quot;22&quot;</code>.
  </div>
</div>


A strict egress policy (see
[outbound restrictions](https://docs-stg.ringleader.dev/security/outbound/outbound-restrictions/))
has to allow each type's registry and the toolchain's download hosts.
[Hosts a strict egress policy must allow](https://docs-stg.ringleader.dev/reference/resources/workstationconfig/#hosts-a-strict-egress-policy-must-allow)
lists them.

## Workstations set up before these package rules

A workstation that already had npm packages before these package rules reached it keeps
what it has. These changes still reach it:

- `updatePolicy: latest` on an npm entry stays within `version`. An entry with
  `version: "3"` stops moving to a new major.
- Changing the `version` of an npm entry installs the new version. A package whose command
  was already present used to stay as it was.
- A new Debian or Ubuntu workstation with npm packages and no `nodejs` devtool gets
  Node.js 24 where it used to get the distribution's. An existing workstation keeps its
  Node.js.
- An entry with `type: pypi`, `go` or `mise` installs. Before, such an entry failed setup.

<div class="callout callout-warning">
  <p class="callout-title">A script can collide with a package</p>
  <div class="callout-body">
    A script that runs <code>npm install -g</code> for a package your configuration declares conflicts
with Ringleader once that package moves. The script writes a second copy that collides
with Ringleader&rsquo;s command link. Drop the package from the script, and let its
<code>updatePolicy</code> move it.
  </div>
</div>


## Add a package

To install a package, list it under `spec.packages` in a workstation or a layer. A bare
name is a system package. An object names the package and, unless it is a system package,
its `type`:

```yaml
spec:
  packages:
    - git                       # a bare name is a system package
    - type: system              # system (default) | npm | pypi | go | mise
      name: htop
      version: "3.2.2"          # optional exact version
      updatePolicy: latest      # ensure (default) | pinned | latest
    - type: npm
      name: prettier
      version: "3"              # the newest 3.x that is at least a day old
    - type: pypi
      name: ruff
    - type: go
      name: golang.org/x/tools/gopls
    - type: mise
      name: terraform
      version: "1.9"
```

[Packages and repositories](https://docs-stg.ringleader.dev/reference/resources/workstationconfig/#packages-and-repositories)
lists what each type accepts as a `name` and a `version`.

## Move a package to another version

To move an npm, PyPI, Go or mise package, change its `version`. The change takes effect on
the next setup run. If the installed version falls outside the new `version`, Ringleader
installs the newest version the new one allows. That can be older than the installed one,
which makes a changed `version` the way to move a package down. A system package's
`version` applies only when it is first installed.

<div class="callout callout-tip">
  <p class="callout-title">Give an exact version</p>
  <div class="callout-body">
    A new <code>version</code> that still allows the installed version moves nothing, so give an exact
version to be sure.
  </div>
</div>


## Let a package replace a system command

To let a package link a command that the operating system already provides, list the
command's name in the entry's `shadows`. An npm entry for npm itself needs both of its
commands, because the workstation's own npm is in `/usr/bin`:

```yaml
packages:
  - type: npm
    name: npm
    shadows: [npm, npx]
```

## Next steps

- [Package repositories](https://docs-stg.ringleader.dev/reference/resources/workstationconfig/#package-repositories)
  adds a third-party apt repository or a Launchpad PPA before packages install.
- [Devtools](https://docs-stg.ringleader.dev/reference/tools/devtools/) lists the curated install recipes for
  development tools, which a configuration can declare beside its packages.

