tweag / opam-nix

Turn opam-based OCaml projects into Nix derivations
MIT License
111 stars 32 forks source link

Most recent stable version is not selected when using `"*"` in queries #53

Open brendanzab opened 1 year ago

brendanzab commented 1 year ago

Describe the bug opam-nix selects ocaml 5.0.0~rc1 over ocaml 5.0.0 when using ocaml-base-compiler = "*"

To Reproduce

Expected behavior opam-nix would select the most recent stable version when "*" is specified. Alternatively it would select the most recent unstable version (there are more recent versions of ocaml-base-compiler now).

Environment

balsoft commented 1 year ago

ocaml-base-compiler = "*" just gets passed along to opam as --packages ocaml-base-compiler, which should select the latest version (to some definition of "latest"). I believe 5.0.0 is a release, and thus should be "stable"?

brendanzab commented 1 year ago

Ahh, wonder why it is not selecting it 😕 – the docs on version ordering are here.

The ~ character is special as it sorts even before the end of sequence (i.e. before anything shorter: "\~" sorts before "", "a\~b" before "a"). It's most convenient for pre-releases, allowing 1.0~beta to be before 1.0.

balsoft commented 1 year ago

Not sure what else you are expecting? It seems to be behaving according to the documentation.

balsoft commented 1 year ago

You might to be looking at the wrong version of opam-repository; mind that by default opam-nix uses the version pinned in flake.lock (at this point, it's 786c55fa77c37f07eceea7d6a9bec04d2225e302)

brendanzab commented 1 year ago

Not sure what else you are expecting? It seems to be behaving according to the documentation.

I would have expected it to select the most recent non-prerelease version (i.e. nothing after the tilde), based on what is on the pinned version of opam-repository. But perhaps I don’t understand opam versioning that well (I’m used to how it works with Cargo).

Maybe I should just set the compiler version explicitly to avoid this in the future, as opposed to relying on *?

As an aside, is there a good way to query what versions of a package in the local opam-repository? At the moment I have just been going into the github repository to check what is at the current commit pinned in my flake, but that seems a little round-about. I assume there’s probably some OCaml tool that can help?

You might to be looking at the wrong version of opam-repository; mind that by default opam-nix uses the version pinned in flake.lock (at this point, it's 786c55fa77c37f07eceea7d6a9bec04d2225e302)

I was looking at the commit of opam-repository that I pinned on my flake. Sorry, I probably should have mentioned that – I was planning to, but I must have forgot. In the commit I linked to it was https://github.com/ocaml/opam-repository/commit/8241abf97ddbcb63f614372f31abeb306312f33c. I guess I’m wondering if this is exposing an issue that is not obvious in the currently pinned version of opam-repository?