Currently opam lock generates a lock file based on what is actually installed in the current switch of the user.
This works fine if the lock file is only used for that user on that exact machine. However when multiple users and multiple platforms come into play, the system breaks apart because some dependencies might not be available on that platform, or an extra dependency might be needed there)
To remedy this, the goal would be for opam lock to generate a lock file on "best-effort basis", meaning that platform-specific disjunctions and conflicts would be kept as-is in the lock file, until opam lock is re-ran on that platform.
Example of workflow:
- user 1 on linux: calls
opam lock on a project that depend on eio_main. The version currently installed is 1.2 and according to the definition of that package eio_linux and eio_posix are installed. The generated lock file should look like this:
depends: [
...
"eio_main" {= "1.2"}
( ("eio_linux" {= "1.2" & os = "linux" & (os-distribution != "centos" | os-version > "7")} &
"eio_posix" {= "1.2" & os != "win32"}) |
"eio_windows" {= "1.2" & os = "win32"})
]
- user 1 pushes that lock file on a public repository
- user 2 on Windows: starts working on that project, calls
opam install --lock . then opam lock. The latter command should merge both what the old lock file and the new state, and in this case end-up with the exact same lock file.
Other examples include lock files where the version number doesn't appear in the opam definition such as:
depends: [
"pkg1" {arch = "x86_64"}
"pkg2" {arch = "arm64"}
]
which would, on x86_64 platforms have a lock file like:
depends: [
"pkg1" {= "1" & arch = "x86_64"}
"pkg2" {arch = "arm64"}
]
and upon calling opam lock on an arm64 platform would end up with:
depends: [
"pkg1" {= "1.0.0" & arch = "x86_64"}
"pkg2" {= "3.2.0" & arch = "arm64"}
]
Prior art: uv (python package manager): https://www.youtube.com/watch?v=gSKTfG1GXYQ
Currently
opam lockgenerates a lock file based on what is actually installed in the current switch of the user.This works fine if the lock file is only used for that user on that exact machine. However when multiple users and multiple platforms come into play, the system breaks apart because some dependencies might not be available on that platform, or an extra dependency might be needed there)
To remedy this, the goal would be for
opam lockto generate a lock file on "best-effort basis", meaning that platform-specific disjunctions and conflicts would be kept as-is in the lock file, untilopam lockis re-ran on that platform.Example of workflow:
opam lockon a project that depend oneio_main. The version currently installed is 1.2 and according to the definition of that packageeio_linuxandeio_posixare installed. The generated lock file should look like this:opam install --lock .thenopam lock. The latter command should merge both what the old lock file and the new state, and in this case end-up with the exact same lock file.Other examples include lock files where the version number doesn't appear in the opam definition such as:
which would, on x86_64 platforms have a lock file like:
and upon calling
opam lockon an arm64 platform would end up with:Prior art: uv (python package manager): https://www.youtube.com/watch?v=gSKTfG1GXYQ