Opam 2 beta: how to list and switch ocaml version?

Is it possible to list available ocaml versions with opam 2-beta?

opam 1 had “opam switch list” but opam 2 does not.

Could not find anything in the opam 2 documentation about this.

I think opam show ocaml should do that?

1 Like

I think opam's cli became a bit confusing in v2. It’s opam switch list-available (see https://github.com/ocaml/opam/issues/3001).

2 Likes

It also supports searching, e.g. opam switch list-available base will give the available base compiler versions, and opam switch list-available buckle can show the BuckleScript switch, etc.

1 Like

Did you find an answer to this? I’ve been trying switch version or check the ocaml version Im using consistently across compilers and toplevel without success:

Check the session where I try switching version but the toplevel doesn’t change but the compiler does.

(base) ❯ opam switch list
#  switch   compiler                    description
→  4.05.0   ocaml-base-compiler.4.05.0  4.05.0
   4.06.0   ocaml-base-compiler.4.06.0  4.06.0
   4.07.0   ocaml-base-compiler.4.07.0  4.07.0
   default  ocaml-system.4.07.0         default
(base) ❯ opam switch 4.06.0
(base) ❯ ocaml --version
The OCaml toplevel, version 4.07.0
(base) ❯ opam switch list
#  switch   compiler                    description
   4.05.0   ocaml-base-compiler.4.05.0  4.05.0
→  4.06.0   ocaml-base-compiler.4.06.0  4.06.0
   4.07.0   ocaml-base-compiler.4.07.0  4.07.0
   default  ocaml-system.4.07.0         default

why isn’t there a SINGLE command that changes version everywhere?


related question: