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.
Many new features made it in (see the complete changelog or release note for the details), but here are a few highlights of this release.
Release highlights
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).
Dependency locking
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
--locked
option.
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.
Pinning sub-directories
This one is completely new: fans of the Monorepo rejoice, opam is now able to handle projects in subtrees of a repository.
- Using
opam pin PROJECT_ROOT --subpath SUB_PROJECT
, opam will look forPROJECT_ROOT/SUB_PROJECT/foo.opam
. This will behave as a pinning toPROJECT_ROOT/SUB_PROJECT
, except that the version-control handling is done inPROJECT_ROOT
. - Use
opam pin PROJECT_ROOT --recursive
to 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
system-wide.
Configuring opam from the command-line
The new opam option
command allows to configure several options,
without requiring manual edition of the configuration files.
For example:
opam option jobs=6 --global
will set the number of parallel build jobs opam is allowed to run (along with the associatedjobs
variable)opam option depext-run-commands=false
disables the use ofsudo
for handling system dependencies; it will be replaced by a prompt to run the installation commands.
The command opam var
is extended with the same format, acting on switch and
global variables.
Try it!
In case you plan a possible rollback, you may want to first backup your
~/.opam
directory.
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!
NOTE: this article is cross-posted on opam.ocaml.org and ocamlpro.com.
About OCamlPro:
OCamlPro is a R&D lab founded in 2011, with the mission to help industrial users benefit from experts with a state-of-the-art knowledge of programming languages theory and practice.
- We provide audit, support, custom developer tools and training for both the most modern languages, such as Rust, Wasm and OCaml, and for legacy languages, such as COBOL or even home-made domain-specific languages;
- We design, create and implement software with great added-value for our clients. High complexity is not a problem for our PhD-level experts. For example, we helped the French Income Tax Administration re-adapt and improve their internally kept M language, we designed a DSL to model and express revenue streams in the Cinema Industry, codename Niagara, and we also developed the prototype of the Tezos proof-of-stake blockchain from 2014 to 2018.
- We have a long history of creating open-source projects, such as the Opam package manager, the LearnOCaml web platform, and contributing to other ones, such as the Flambda optimizing compiler, or the GnuCOBOL compiler.
- We are also experts of Formal Methods, developing tools such as our SMT Solver Alt-Ergo (check our Alt-Ergo Users' Club) and using them to prove safety or security properties of programs.
Please reach out, we'll be delighted to discuss your challenges: contact@ocamlpro.com or book a quick discussion.
Most Recent Articles
2024
- opam 2.3.0 release!
- Optimisation de Geneweb, 1er logiciel français de Généalogie depuis près de 30 ans
- Alt-Ergo 2.6 is Out!
- Flambda2 Ep. 3: Speculative Inlining
- opam 2.2.0 release!
- Flambda2 Ep. 2: Loopifying Tail-Recursive Functions
- Fixing and Optimizing the GnuCOBOL Preprocessor
- OCaml Backtraces on Uncaught Exceptions
- Opam 102: Pinning Packages
- Flambda2 Ep. 1: Foundational Design Decisions
- Behind the Scenes of the OCaml Optimising Compiler Flambda2: Introduction and Roadmap
- Lean 4: When Sound Programs become a Choice
- Opam 101: The First Steps
2023
- Maturing Learn-OCaml to version 1.0: Gateway to the OCaml World
- The latest release of Alt-Ergo version 2.5.1 is out, with improved SMT-LIB and bitvector support!
- 2022 at OCamlPro
- Autofonce, GNU Autotests Revisited
- Sub-single-instruction Peano to machine integer conversion
- Statically guaranteeing security properties on Java bytecode: Paper presentation at VMCAI 23
- Release of ocplib-simplex, version 0.5