opam 2.0 Beta is out!
UPDATE (2017-02-14): A beta2 is online, which fixes issues and performance of the
opam buildcommand. Get the new binaries, or recompile the opam-devel package and replace the previous binary.
We are pleased to announce that the beta release of opam 2.0 is now live! You can try it already, bootstrapping from a working 1.2 opam installation, with:
opam update; opam install opam-devel
With about a thousand patches since the last stable release, we took the time to gather feedback after our last announcement and implemented a couple of additional, most-wanted features:
- An opam buildcommand that, from the root of a source tree containing one or more package definitions, can automatically handle initialisation and building of the sources in a local switch.
- Support for repository signing through the external Conex tool, being developed in parallel.
There are many more features, like the new opam clean and opam admin
commands, a new archive caching system, etc., but we'll let you check the full
changelog.
We also improved still on the already announced features, including compilers as packages, local switches, per-switch repository configuration, package file tracking, etc.
The updated documentation is at https://opam.ocaml.org/doc/2.0/. If you are developing in opam-related tools, you may also want to browse the new APIs.
Try it out
Please try out the beta, and report any issues or missing features. You can:
- Build it from source in opam, as shown above (opam install opam-devel)
- Use the pre-built binaries.
- Building from the source tarball:
download here
and build using ./configure && make lib-ext && makeif you have OCaml >= 4.01 already available;make coldotherwise
- Or directly from the
git tree, following the
instructions included in the README. Some files have been moved around, so if
your build fails after you updated an existing git clone, try to clean it up
(git clean -dx).
Some users have been using the alpha for the past months without problems, but you may want to keep your opam 1.2 installation intact until the release is out. An easy way to do this is with an alias:
alias opam2="OPAMROOT=~/.opam2 path/to/opam-2-binary"
Changes to be aware of
Command-line interface
- opam switch createis now needed to create new switches, and- opam switchis now much more expressive
- opam listis also much more expressive, but be aware that the output may have changed if you used it in scripts
- new commands:
- opam build: setup and build a local source tree
- opam clean: various cleanup operations (wiping caches, etc.)
- opam admin: manage software repositories, including upgrading them to opam 2.0 format (replaces the- opam-admintool)
- opam env,- opam exec,- opam var: shortcuts for the- opam configsubcommands
 
- opam repository addwill now setup the new repository for the current switch only, unless you specify- --all
- Some flags, like --test, now apply to the packages listed on the command-line only. For example,opam install lwt --testwill build and install lwt and all its dependencies, but only build/run the tests of thelwtpackage. Test-dependencies of its dependencies are also ignored
- The new opam install --soft-requestis useful for batch runs, it will maximise the installed packages among the requested ones, but won't fail if all can't be installed
As before, opam is self-documenting, so be sure to check opam COMMAND --help
first when in doubt. The bash completion scripts have also been thoroughly
improved, and may help navigating the new options.
Metadata
There are both a few changes (extensions, mostly) to the package description format, and more drastic changes to the repository format, mainly related to translating the old compiler definitions into packages.
- opam will automatically update, internally, definitions of pinned packages as well as repositories in the 1.2 format
- however, it is faster to use repositories in the 2.0 format directly. To that
end, please use the opam admin upgradecommand on your repositories. The--mirroroption will create a 2.0 mirror and put in place proper redirections, allowing your original repository to retain the old format
The official opam repository at https://opam.ocaml.org remains in 1.2 format for now, but has a live-updated 2.0 mirror to which you should be automatically redirected. It cannot yet accept package definitions in 2.0 format.
Package format
- Any available:constraints based on the OCaml compiler version should be rewritten into dependencies to theocamlpackage
- Separate build:andinstall:instructions are now required
- It is now preferred to include the old urlanddescrfiles (containing the archive URL and package description) in theopamfile itself: (see the newsynopsis:anddescription:fields, and the url {} file section)
- Building tests and documentation should now be part of the main build:instructions, using the{test}and{doc}filters. Thebuild-test:andbuild-doc:fields are still supported.
- It is now possible to use opam variables within dependencies, for example
depends: [ "foo" {= version} ], for a dependency to packagefooat the same version as the package being defined, ordepends: [ "bar" {os = "linux"} ]for a dependency that only applies on Linux.
- The new conflict-class:field allows mutual conflicts among a set of packages to be declared. Useful, for example, when there are many concurrent, incompatible implementations.
- The ocaml-version:field has been deprecated for a long time and is no longer accepted. This should now be a dependency on theocamlpackage
- Three types of checksums are now accepted: you should use md5=<hex-value>,sha256=<hex-value>orsha512=<hex-value>. We'll be gradually deprecating md5 in favour of the more secure algorithms; multiple checksums are allowed
- Patches supplied in the patches:field must apply withpatch -p1
- The new setenv:field allows packages to export updates to environment variables;
- Custom fields x-foo:can be used for extensions and external tools
- """delimiters allow unescaped strings
- &has now the customary higher precedence than- |in formulas
- Installed files are now automatically tracked meaning that the remove:field is usually no longer required.
The full, up-to-date specification of the format can be browsed in the manual.
Repository format
In the official, default repository, and also when migrating repositories from older format versions, there are:
- A virtual ocamlpackage, that depends on any implementation of the OCaml compiler. This is what packages should depend on, and the version is the corresponding base OCaml version (e.g.4.04.0for the4.04.0+fpcompiler). It also defines various configuration variables, seeopam config list ocaml.
- Three mutually-exclusive packages providing actual implementations of the
OCaml toolchain:
- ocaml-base-compileris the official releases
- ocaml-variants.<base-version>+<variant-name>contains all the other variants
- ocaml-system-compilermaps to a compiler installed on the system outside of opam
 
The layout is otherwise the same, apart from:
- The compilers/directory is ignored
- A repofile should be present, containing at least the lineopam-version: "2.0"
- The indexes for serving over HTTP have been simplified, and urls.txtis no longer needed. Seeopam admin index --help
- The archives/directory is no longer used. The cache now uses a different format and is configured through therepofile, defaulting tocache/on the same server. Seeopam admin cache --help
Feedback
Thanks for trying out the beta! Please let us have feedback, preferably to the opam tracker; other options include the opam-devel list and #opam IRC channel on Freenode.