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

**URL:** https://discuss.ocaml.org/t/opam-2-beta-how-to-list-and-switch-ocaml-version/1390
**Category:** Ecosystem
**Tags:** opam
**Created:** [January 4, 2018, 5:57pm UTC](https://discuss.ocaml.org/t/opam-2-beta-how-to-list-and-switch-ocaml-version/1390 "2018-01-04T17:57:16Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jbulow](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jbulow/32/644_2.png) [@jbulow](https://discuss.ocaml.org/u/jbulow)
#### Post date: [January 4, 2018, 5:57pm UTC](https://discuss.ocaml.org/t/opam-2-beta-how-to-list-and-switch-ocaml-version/1390/1 "2018-01-04T17:57:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dra27](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dra27/32/5294_2.png) [@dra27](https://discuss.ocaml.org/u/dra27)
#### Post date: [January 4, 2018, 7:59pm UTC](https://discuss.ocaml.org/t/opam-2-beta-how-to-list-and-switch-ocaml-version/1390/2 "2018-01-04T19:59:07Z")

</div>

I think `opam show ocaml` should do that?

---

<div class="post-metadata">

### Author: ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)
#### Post date: [January 4, 2018, 8:21pm UTC](https://discuss.ocaml.org/t/opam-2-beta-how-to-list-and-switch-ocaml-version/1390/3 "2018-01-04T20:21:41Z")

</div>

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](https://github.com/ocaml/opam/issues/3001)).

---

<div class="post-metadata">

### Author: ![bobbypriambodo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bobbypriambodo/32/179_2.png) [@bobbypriambodo](https://discuss.ocaml.org/u/bobbypriambodo)
#### Post date: [January 5, 2018, 3:10am UTC](https://discuss.ocaml.org/t/opam-2-beta-how-to-list-and-switch-ocaml-version/1390/4 "2018-01-05T03:10:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![rene\_sax](https://avatars.discourse-cdn.com/v4/letter/r/0ea827/32.png) [@rene\_sax](https://discuss.ocaml.org/u/rene_sax)
#### Post date: [November 16, 2019, 6:34pm UTC](https://discuss.ocaml.org/t/opam-2-beta-how-to-list-and-switch-ocaml-version/1390/6 "2019-11-16T18:34:18Z")

</div>

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.

```auto
(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:

- [How does one switch ocaml version?](https://discuss.ocaml.org/t/how-does-one-switch-ocaml-version/4702)
- [How does one check the ocaml version one is using?](https://discuss.ocaml.org/t/how-does-one-check-the-ocaml-version-one-is-using/4705)

---

<div class="post-metadata">

### Author: ![ancolie](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ancolie/32/6189_2.png) [@ancolie](https://discuss.ocaml.org/u/ancolie)
#### Post date: [December 28, 2019, 5:31pm UTC](https://discuss.ocaml.org/t/opam-2-beta-how-to-list-and-switch-ocaml-version/1390/7 "2019-12-28T17:31:08Z")

</div>

You need to do something like: `eval "$(opam env)"`.
