-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Wishlist for Opam Lock #5857
Comments
Thank you for your detailed explanations. First, i want to explain the origin of In the current state of opam, there is no command that permit to generate directly the file you want. Your case is a good candidate for a plugin, that would generate that file ; using opam-lib, like that there is no need to reimplement what opam already does. On the "normal" vs "development" dependencies, we introduced in opam 2.2 |
The issue with this definition is that "the installed packages required by the project" doesn't mean much when the state of the repository is unknown. I would personally argue that having the state of the repositories should be required for lock files |
Thank you @rjbou for your answer. I was not aware of
I think this is actually our use case. But as @kit-ty-kate says, if the lock file does not actually guarantee that, say, Another important point is: how to extend this workflow to the case where many developers are working on the same project, with strict review processes etc.? If all developers regularly update the lock file, the lock file will go back and forth between various versions of installed packages. For instance, let's assume that Alice has For us, the "developer" that can attest is actually the CI. The goal is indeed to be able to attest that if you compile Octez with its lock file, you are guaranteed to obtain a version that is the one that has been successfully tested by the CI of Octez. That being said, someone read this post and contacted me privately to suggest that If you're curious, here is the updated version of the script that updates our lock files: https://gitlab.com/tezos/tezos/-/blob/8c0ded8f28cd56e7cf20d9094969dad80a2741e7/scripts/update_opam_lock.sh (edit: since then the script has been simplified; last version can be found in https://gitlab.com/tezos/tezos/-/blob/2dbdd532c15e46c40a22e5867642efb2f70152da/scripts/update_opam_lock.sh). The script could be made simpler:
But those two points are probably out of topic here. |
Another minor point that came up: |
Related discussion happening in CycloneDX/cdxgen#793 |
We are trying to use opam lock files in Octez, an implementation of the Tezos blockchain. We find that lock files do not completely solve our use case. We thought of sharing why here, in case there are options that we did not consider, and in case our use case is of interest to the authors of opam for potential future improvements.
Our Requirements
1) Reproducibility of Building Octez
The opam lock file would ensure that developers, users and our CI build Octez using the exact same dependencies (for a given platform). This means:
2) Reproducibility of Generating the Lock File
Developers should be able to run a script that generates the lock file, and the same lock file should be generated for all developers (for a given platform). This means:
_opam
);ocaml/opam-repository
.3) Flexibility for Developers
While we do want to fix the version of Octez dependencies, we also want to let developers install development tools such as
utop
andmerlin
, without having those in the lock file since they are not needed by all users nor by our CI.Ideally
Ideally, given a set of dependencies
DEPS
with some version constraints, a set of development toolsDEV-DEPS
, and a givenHASH
of the public opam repository, we would be able to ask opam to:At the same time, or as a follow-up step, we would be able to ask opam to:
Finally, we would be able to ask opam to:
Our Current Solution
To Generate the Lock File
DEPS
is an opam file that depends on our dependencies, with some version constraints.DEV-DEPS
is an opam file that depends on some development tools likeutop
andmerlin
.We do the following:
ocaml/opam-repository
, checkout a givenHASH
;opam admin filter --remove --has-flag avoid-version
;opam repository
withset-url
oradd
to add this clone, and remove thedefault
repository;opam install --yes --deps-only --criteria=-notuptodate,+removed DEPS DEV-DEPS
;opam remove utop
;opam lock DEPS
;default
repository.This solution:
Let's explain the different steps.
ocaml/opam-repository
so that:opam admin filter
on it to remove some unwanted packages (namely those with flagavoid-version
, which are otherwise sometimes selected because apparently using--criteria
breaks version avoidance).default
repository because we want to ensure that only packages from the commit hash that we cloned are available._opam
). It will sometimes select those packages, resulting in unwanted packages (with flagavoid-version
) in the lock file.--dont-select
because we don't want to break other switches. (I think. The documentation of this flag is rather confusing.)opam install
on bothDEPS
andDEV-DEPS
because even though we only wantDEPS
in the lock file, we want a solution that is compatible withDEV-DEPS
.DEPS
norDEV-DEPS
), we are merely trying to ask the solver to find a solution and write it down. This step can thus take much longer than necessary, as it requires compiling dependencies.opam install
with-notuptodate
because our script is meant to upgrade all packages. It also gives a better chance at producing the same solution for everyone.opam install
with+removed
because we want it to find a minimal solution.DEV-DEPS
.opam remove utop
so that it does not appear in the lock file.utop
is inDEV-DEPS
but not inDEPS
. It is however an optional dependency ofpyml
, which is inDEPS
. Ifutop
is installed when we runopam lock
, it thus ends up in the lock file.utop
becomes a non-optional dependency (inDEPS
), the lock file will be broken. If one day another package suffers from the same issue, we will have to update our script.utop
, which is wasted time.To Install the Lock File
To install the lock file, we:
ocaml/opam-repository#hash
and remove thedefault
one;opam install --deps-only
on the lock file (and, optionally, onDEV-DEPS
);default
repository.Let's explain the different steps.
#hash
to the opam repository URL to make sure that tarball hashes are the same as the one that were chosen when generating the lock file.default
repository after that so that devs can install other libraries and tools that they may want locally.Other Solutions we Looked At
Switch Exports
opam switch export --full
is closer to what we need from a lock file because it contains hashes, but full exports have other issues:opam switch --help
so I have to assume the worst if I don't want to rely on unspecified behavior.Calling the Solver Manually
We are considering the following solution to generate our lock files but did not try it yet:
avoid-version
;DEPS
andDEV-DEPS
;DEPS
(and notDEV-DEPS
);Basically, this amounts to reimplementing parts of opam.
The text was updated successfully, but these errors were encountered: