Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
brendanzab opened this issue Sep 10, 2023 · 5 comments
Open

Comments

@brendanzab
Copy link

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

To Reproduce

  • Clone https://github.com/brendanzab/language-garden.git and checkout brendanzab/language-garden@97f9f2d
  • Check the ocaml version:
    $ nix develop --command ocaml --version
    The OCaml toplevel, version 5.0.0
  • Apply the following diff:
    diff --git a/flake.nix b/flake.nix
    index 012f4aa..2134b1d 100644
    --- a/flake.nix
    +++ b/flake.nix
    @@ -72,7 +72,7 @@
           # when building the opam project with `opam-nix`.
           query = devPackagesQuery // {
             # Force the ocaml compiler to be taken from opam-repository:
    -        ocaml-base-compiler = "5.0.0"; # Fix for opam-nix choosing 5.0.0~rc1 over 5.0.0
    +        ocaml-base-compiler = "*";
           };
    
           # Package-specific derivation overrides.
  • Check the ocaml version:
    $ nix develop --command ocaml --version
    The OCaml toplevel, version 5.0.0~rc1

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

  • OS name + version: macOS 13.4.1
  • Version of the code: e83bd1d
@balsoft
Copy link
Collaborator

balsoft commented Sep 11, 2023

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
Copy link
Author

brendanzab commented Sep 11, 2023

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
Copy link
Collaborator

balsoft commented Sep 19, 2023

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

@balsoft
Copy link
Collaborator

balsoft commented Sep 19, 2023

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
Copy link
Author

brendanzab commented Sep 20, 2023

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 ocaml/opam-repository@8241abf. I guess I’m wondering if this is exposing an issue that is not obvious in the currently pinned version of opam-repository?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants