Opam prevent preview in upgrade

Hi all,

Today, opam upgrade (I use 2.1) proposed me to upgrade to preview version of merlin and ocaml-lsp-server. Is there a way (a command line option) to prevent installation of preview / alpha / beta version?

By the way, is there a reason that the documentation on the opam web site is stuck to version 2.0? I tried to read documentation on the subject but were not able to find anything.

Have a good day

Did you see that upgrade proposal on a non-4.13 version of OCaml?

Normally, the preview version of ocaml-lsp and merlin are only available on 4.13, and they are the only version that works with this version.

I’m on 4.12 and the upgrade command propose me to upgrade to 4.13 (together with the preview versions).

This proposal should fix your issue: Avoid previews when possible by kit-ty-kate · Pull Request #19674 · ocaml/opam-repository · GitHub
If i understand what you want correctly, you’d be willing to upgrade to OCaml 4.13 but not as long as merlin/ocaml-lsp are only previews, am I correct?

Yes, I would like to prevent upgrading to 4.13 while some required packaged are still previews. But more generally I thought someone would be willing to keep a well tested set of versions and avoid previews.

Yes I too was wondering about this. When I want to install ocaml-lsp in a switch now I am being prompted to install 1.9.0~4.13preview when I am mostly interested in installing ocaml lsp 1.8.2. I was able to solve this issue for myself by doing

opam install ocaml-lsp-server.1.8.2

But yes, I agree that the preview version should be an opt in rather than default offered to people.

Actually I just had a look at @kit-ty-kate 's linked PR – it looks like the issue will be resolved when the PR is merged – Thanks!!

It’s merged - thanks for the fix, @kit-ty-kate! Just cross-posting the comment I made with examples of how this changes:

  • If you are in a 4.13 switch (e.g. opam switch create 4.13 ocaml-base-compiler.4.13.0) and you opam install merlin, you will get the 4.13 preview, but it will upgrade when the upstream release happens
  • If you are in a 4.12 switch (e.g. opam switch create 4.12 ocaml-base-compiler.4.12.1) and you opam install merlin, you will get 4.3.1-412 (i.e. latest stable) as before
  • opam will not upgrade to OCaml 4.13 if you have installed merlin in the switch and, when doing opam switch create . opam will not select 4.13 if merlin (or lsp-server) are included in the dependencies of the opam files which get pinned.

So, for example:

opam switch create my-project ocaml-base-compiler.4.12.1
opam switch set-invariant ocaml-base-compiler
opam install merlin
opam upgrade

will stick with OCaml 4.12.1, but if you:

opam remove merlin
opam upgrade

you’ll get upgraded to OCaml 4.13.0. NB in opam 2.0.x, none of this applies - you’ll get the preview version, but opam 2.0.x doesn’t tend to upgrade compilers.