opam 2.1.0 alpha is here!
We are happy to announce a alpha for opam 2.1.0, one year and a half in the making after the release of 2.0.0.
The two following features have been around for a while as plugins and are now completely integrated in the core of opam. No extra installs needed anymore, and a more smooth experience.
Seamless integration of System dependencies handling (a.k.a. "depexts")
A number of opam packages depend on tools or libraries installed on the system, which are out of the scope of opam itself. Previous versions of opam added a specification format, and opam 2.0 already handled checking the OS and extracting the required system package names.
However, the workflow generally involved letting opam fail once, then installing the dependencies and retrying, or explicitely using the opam-depext plugin, which was invaluable for CI but still incurred extra steps.
With opam 2.1.0, depexts are seamlessly integrated, and you basically won't have to worry about them ahead of time:
- Before applying its course of actions, opam 2.1.0 checks that external
dependencies are present, and will prompt you to install them. You are free to
let it do it using
sudo, or just run the provided commands yourself.
- It is resilient to depexts getting removed or out of sync.
- Opam 2.1.0 detects packages that depend on stuff that is not available on your OS version, and automatically avoids them.
This is all fully configurable, and can be bypassed without tricky commands when you need it (e.g. when you compiled a dependency yourself).
To share a project for development, it is often necessary to be able to reproduce the exact same environment and dependencies setting — as opposed to allowing a range of versions as opam encourages you to do for releases.
For some reason, most other package managers call this feature "lock files".
Opam can handle those in the form of
[foo.]opam.locked files, and the
With 2.1.0, you no longer need a plugin to generate these files: just running
opam lock will create them for existing
opam files, enforcing the exact
version of all dependencies (including locally pinned packages).
If you check-in these files, new users would just have run
opam switch create . --locked on a fresh clone to get a local switch ready to
build the project.
This one is completely new: fans of the Monorepo rejoice, opam is now able to handle projects in subtrees of a repository.
opam pin PROJECT_ROOT --subpath SUB_PROJECT, opam will look for
PROJECT_ROOT/SUB_PROJECT/foo.opam. This will behave as a pinning to
PROJECT_ROOT/SUB_PROJECT, except that the version-control handling is done in
opam pin PROJECT_ROOT --recursiveto automatically lookup all sub-trees with opam files and pin them.
Opam switches are now defined by invariants
Previous versions of opam defined switches based on base packages, which typically included a compiler, and were immutable. Opam 2.1.0 instead defines them in terms of an invariant, which is a generic dependency formula.
This removes a lot of the rigidity
opam switch commands had, with little
changes on the existing commands. For example,
opam upgrade ocaml commands are
now possible; you could also define the invariant as
ocaml-system and have
its version change along with the version of the OCaml compiler installed
Configuring opam from the command-line
opam option command allows to configure several options,
without requiring manual edition of the configuration files.
opam option jobs=6 --globalwill set the number of parallel build jobs opam is allowed to run (along with the associated
opam option depext-run-commands=falsedisables the use of
sudofor handling system dependencies; it will be replaced by a prompt to run the installation commands.
opam var is extended with the same format, acting on switch and
In case you plan a possible rollback, you may want to first backup your
The upgrade instructions are unchanged:
- Either from binaries: run
$~ bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) --version 2.1.0~alpha"
or download manually from the Github "Releases" page to your PATH.
- Or from source, manually: see the instructions in the README.
You should then run:
opam init --reinit -ni
This is still a alpha, so a few glitches or regressions are to be expected. Please report them to the bug-tracker. Thanks for trying it out, and hoping you enjoy!
OCamlPro is a R&D lab founded in 2011, with the mission to help industrial users benefit from state-of-the art programming languages like OCaml and Rust.
We design, create and implement custom ad-hoc software for our clients. We also have a long experience in developing and maintaining open-source tooling for OCaml, such as Opam, TryOCaml, ocp-indent, ocp-index and ocp-browser, and we contribute to the core-development of OCaml, notably with our work on the Flambda optimizer branch.
Another area of expertise is that of Formal Methods, with tools such as our SMT Solver Alt-Ergo (check our Alt-Ergo Users'). We also provide vocational trainings in OCaml and Rust, and we can build courses on formal methods on-demand. Please reach out, we'll be delighted to discuss your challenges: firstname.lastname@example.org or book a quick discussion.