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

Comparing package versions with opam cli #6118

Open
mbarbin opened this issue Jul 25, 2024 · 10 comments
Open

Comparing package versions with opam cli #6118

mbarbin opened this issue Jul 25, 2024 · 10 comments
Assignees
Labels
Milestone

Comments

@mbarbin
Copy link
Contributor

mbarbin commented Jul 25, 2024

Hello!

I don't think this is an issue with opam, it's more like a question: What is the syntax in opam for a package version that denote a pre-release version?

I was trying to follow https://semver.org/#spec-item-9 but was surprised by this:

$ opam install ppxlib.0.33.0
The following actions will be performed:
=== downgrade 1 package
  ↘ ppxlib                      0.33.0-preview.1 to 0.33.0

(I would have expected that 0.33.0-preview.1 < 0.33.0, and thus this install being an upgrade, not a downgrade.

I sort of recall seeing perhaps '~' used as a separator. Is this the way? (as in, I should have named the package 0.33.0~preview.1 instead). I couldn't find '~' in the semver doc. Is this a different convention?

Sorry if it's a duplicate. I am not well versed in pre-release packages with opam, and trying to establish habits that will work well.
Thank you!

@kit-ty-kate
Copy link
Member

The version ordering is explain in the manual: https://opam.ocaml.org/doc/Manual.html#version-ordering
but in a nutshell:

  • opam follows Debian versioning scheme, not semver
  • ~ (tilde) is indeed the right separator for what you are trying to achieve

@kit-ty-kate
Copy link
Member

You can also find examples of that very same package in https://github.com/ocaml/opam-repository/blob/master/packages/ppxlib/ppxlib.0.32.1~5.2preview/opam
Out of curiosity ppxlib.0.33.0-preview.1 is not present in opam-repository (although the stable 0.33.0 release is), does this package come from a custom repository?

@mbarbin
Copy link
Contributor Author

mbarbin commented Jul 25, 2024

Thanks a lot!

I was confused a bit by https://github.com/ocaml/opam?tab=readme-ov-file#versioning but I understand now this statement is about the version of the opam binary itself, not a statement about the version of user packages.

Out of curiosity ppxlib.0.33.0-preview.1 is not present in opam-repository (although the stable 0.33.0 release is), does this package come from a custom repository?

Yes, I had published a preview here while working on some PR with the ppxlib devs.

I will adjust my process to use the '~' separator then, thanks again!

@mbarbin mbarbin closed this as completed Jul 25, 2024
@mbarbin
Copy link
Contributor Author

mbarbin commented Jul 26, 2024

Thinking about this a bit @kit-ty-kate, what do you think about adding a quick sanity check opam sub command allowing some validation and comparison of 2 versions, exposing the same logic as used by the rest of the opam system?

I'm thinking something as simple as:

$ opam admin compare-package-versions 0.33.0-preview.1 0.33
0.33.0-preview.1 > 0.33

I'm imagining this could be a good way to double check things when in doubt (the spec can get a bit tricky with all the special rules and characters to do this mentally).

@kit-ty-kate
Copy link
Member

That looks useful yes. Contribution would be welcome, or if you don't have the time you can open a ticket and we'll get to it when we have some time.

As a side-note, currently that can be done using the OCaml REPL:

#use "topfind";;
#require "opam-core";;
OpamVersionCompare.compare "0.33.0-preview.1" "0.33";;
- : int = 1

mbarbin added a commit to mbarbin/opam that referenced this issue Jul 26, 2024
This follows a discussion in ocaml#6118

Signed-off-by: Mathieu Barbin <[email protected]>
kit-ty-kate pushed a commit to mbarbin/opam that referenced this issue Jul 26, 2024
This follows a discussion in ocaml#6118

Signed-off-by: Mathieu Barbin <[email protected]>
@mbarbin
Copy link
Contributor Author

mbarbin commented Jul 26, 2024

Thank you for showing how to do it with the OCaml REPL!

I opened a PR to add this in the doc (as you saw and already approved, Thank you!).

Given the new doc note, and that there's already a way to do this, I don't really know anymore if it is worth adding a sub command too. I think I am happy with the REPL thing. What do you say?

@kit-ty-kate
Copy link
Member

Given the new doc note, and that there's already a way to do this, I don't really know anymore if it is worth adding a sub command too. I think I am happy with the REPL thing. What do you say?

i don't know. I suppose having a separate command would be a bit nicer but i wonder if it would actually be useful to more people than just those who would be happy with the REPL solution already.

@mbarbin mbarbin changed the title Question about pre-release version format (~ vs - and semver) Comparing package versions with opam cli Jul 26, 2024
@mbarbin mbarbin reopened this Jul 26, 2024
@mbarbin
Copy link
Contributor Author

mbarbin commented Jul 26, 2024

I suppose having a separate command would be a bit nicer

OK. I'll see what I can do. I think I can squeeze an attempt into my dev schedule in the near term. If anything, I'd be interested about finding my ways into the opam cli. Thanks!

Please assign the issue to me.

@kit-ty-kate
Copy link
Member

Please assign the issue to me.

done

@mbarbin
Copy link
Contributor Author

mbarbin commented Sep 30, 2024

Work in progress in #6197

@kit-ty-kate kit-ty-kate added this to the 2.4.0~alpha1 milestone Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants