OCaml opam¶
- ID
opam- Home page
- Version requirement
>= 2
- Platforms
🅱️ BSD · 🐧 Linux · 🍎 macOS
- Operations
installed·search·install·upgrade·upgrade_all·remove·sync- purl types
pkg:opam- CLI name
opam- Every call
opam --color=never --yes <command>- Issues and PRs
- Source
opam is the OCaml package manager (https://opam.ocaml.org).
Every listing goes through --short --columns=name,version, which opam
documents as dropping the header and joining columns with a space, giving one
name version pair per line with no alignment to strip.
No outdated: opam list --upgradable reports what would move, but naming both
the installed and the candidate version in one listing needs a column set this
definition cannot verify against an upstream sample, so the operation is left
undeclared and upgrade --all still works.
Every operation targets opam’s currently active switch, which is whatever
OPAMSWITCH or the current directory resolves to, exactly as a bare opam
call in the same shell would. Per-switch targeting is not supported yet.
What mpm adds to opam¶
Through mpm, opam gains --exact and --extended search, to narrow to exact names or match descriptions.
Bigger still, mpm reaches across every manager at once: mpm installed and mpm outdated cover opam alongside every other manager you run in one table, mpm upgrade --all updates them together, and mpm sbom exports the whole machine as one bill of materials.
Every mpm command also gains --dry-run and --plan previews, cross-scheme version comparison and purl identifiers. See manager augmentations for how each one is built.
Your opam commands, in mpm¶
You already know opam: each operation maps one-to-one onto mpm, in an interface shared by every manager.
To… |
With |
With |
|---|---|---|
List what’s installed |
|
|
Search for a package |
|
|
Install a package |
|
|
Upgrade one package |
|
|
Upgrade everything |
|
|
Remove a package |
|
|
Prefix any command above with --dry-run to simulate the underlying manager calls without touching the system: the safe way to watch what mpm would do before trusting it.
Operations¶
Operation |
Supported |
Notes |
|---|---|---|
|
✓ |
|
|
||
|
||
|
✓ |
exact and extended search backfilled by |
|
✓ |
|
|
✓ |
|
|
✓ |
|
|
✓ |
|
|
✓ |
|
|
||
|
Selecting and configuring opam¶
Deselect opam for a single run with --no-opam, or persist the choice in your configuration:
[mpm]
opam = false
The arguments and environment variables listed in the box atop this page are forced on every opam call, so runs stay quiet, non-interactive and reproducible: the defaults you would set in CI anyway.
Keep it enabled but tune how mpm drives it with a per-manager override:
[mpm.managers.opam]
timeout = 900
mpm config-template opam prints every overridable attribute as a ready-to-paste block.
Recipes¶
A few jobs you would otherwise script around opam, one mpm command each:
Snapshot and clone a machine:
mpm --opam dump opam.toml, thenmpm restore opam.tomlon the next one.Export a compliance SBOM:
mpm --opam sbom(CycloneDX by default,--spdxfor SPDX).
Privilege escalation¶
mpm runs this manager as the current user and never prepends sudo by default. Flip the policy for its privileged operations with --sudo or the per-manager sudo override.
None of its operations needs root.
See privilege escalation for the full policy.
Cooldown¶
State of OCaml opam’s release-age gating, from the cooldown support table:
Status: ❌ None
A cooldown only pays off where a compromised release can be withdrawn while the clock runs, and can only be emulated where the registry dates its releases. From the retraction table:
Registry: Git-manifest indexes
Retraction: Index revert: reverting the manifest, Portfile or derivation commit withdraws the version
Publish date: ❌ only the commit date, which is client-set and trivially backdated
With --cooldown set, mpm skips this manager’s install and upgrade operations rather than run them unguarded (fail-closed); --allow-unsupported-managers opts back in.
Version probe¶
The version is probed by running:
$ opam --version
2.1.5
and extracted with:
r"(?P<version>\d+(?:\.\d+)+\S*)"
Reference traces¶
Raw native outputs captured in the bundled definition: the reference mpm’s parsers were written against. If you know OCaml opam well and a transcript below looks wrong, or a newer release changed its output format, report it.
$ opam list --installed --short --columns=name,version
base-bigarray base
base-threads base
dune 3.11.1
ocaml 4.14.1
ocamlfind 1.9.6
$ opam list --search {query} --short --columns=name,version
lwt 5.7.0
lwt_ppx 2.1.0
lwt_ssl 1.2.0
Feed any of these through mpm and the raw output becomes one uniform table, the same shape for every manager: filter it, project columns, or export it (mpm --opam installed --output json, or csv, toml, yaml), each package carrying a purl and a version comparable across managers.
Changelog¶
7.7.0.dev0(unreleased)Add the OCaml opam package manager with
installed,search,install,upgrade,removeandsyncsupport. Listings go through--short --columns=name,version, which drops the header and joins columns with a space.