Opam sees 0.16.0, but opam install bonsai goes for 0.15.1

opam show bonsai shows 0.16.0, but opam install bonsai goes for 0.15.1

What am I doing wrong ?

[nix-shell:~]$ opam show bonsai
[NOTE] External dependency handling not supported for OS family 'nixos'.
       You can disable this check using 'opam option --global depext=false'

<><> bonsai: information on all versions ><><><><><><><><><><><><><><><><><><><>
name         bonsai
all-versions v0.13.0  v0.14.0  v0.15.0  v0.15.1  v0.16.0

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><>
version      v0.16.0
repository   default
url.src      "https://ocaml.janestreet.com/ocaml-core/v0.16/files/bonsai-v0.16.0.tar.gz"
url.checksum "sha256=1d68aab713659951eba5b85f21d6f9382e0efa8579a02c3be65d9071c6e86303"
homepage     "https://github.com/janestreet/bonsai"
doc          "https://ocaml.janestreet.com/ocaml-core/latest/doc/bonsai/index.html"
bug-reports  "https://github.com/janestreet/bonsai/issues"
dev-repo     "git+https://github.com/janestreet/bonsai.git"
authors      "Jane Street Group, LLC"
maintainer   "Jane Street developers"
license      "MIT"
depends      "ocaml" {>= "4.14.0"}
             "async" {>= "v0.16" & < "v0.17"}
             "async_durable" {>= "v0.16" & < "v0.17"}
             "async_extra" {>= "v0.16" & < "v0.17"}
             "async_js" {>= "v0.16" & < "v0.17"}
             "async_kernel" {>= "v0.16" & < "v0.17"}
             "async_rpc_kernel" {>= "v0.16" & < "v0.17"}
             "async_rpc_websocket" {>= "v0.16" & < "v0.17"}
             "babel" {>= "v0.16" & < "v0.17"}
             "base" {>= "v0.16" & < "v0.17"}
             "core" {>= "v0.16" & < "v0.17"}
             "core_bench" {>= "v0.16" & < "v0.17"}
             "core_kernel" {>= "v0.16" & < "v0.17"}
             "core_unix" {>= "v0.16" & < "v0.17"}
             "expect_test_helpers_core" {>= "v0.16" & < "v0.17"}
             "fuzzy_match" {>= "v0.16" & < "v0.17"}
             "incr_dom" {>= "v0.16" & < "v0.17"}
             "incr_map" {>= "v0.16" & < "v0.17"}
             "indentation_buffer" {>= "v0.16" & < "v0.17"}
             "ordinal_abbreviation" {>= "v0.16" & < "v0.17"}
             "patdiff" {>= "v0.16" & < "v0.17"}
             "polling_state_rpc" {>= "v0.16" & < "v0.17"}
             "ppx_css" {>= "v0.16" & < "v0.17"}
             "ppx_here" {>= "v0.16" & < "v0.17"}
             "ppx_jane" {>= "v0.16" & < "v0.17"}
             "ppx_let" {>= "v0.16" & < "v0.17"}
             "ppx_pattern_bind" {>= "v0.16" & < "v0.17"}
             "ppx_typed_fields" {>= "v0.16" & < "v0.17"}
             "profunctor" {>= "v0.16" & < "v0.17"}
             "sexp_grammar" {>= "v0.16" & < "v0.17"}
             "sexplib0" {>= "v0.16" & < "v0.17"}
             "textutils" {>= "v0.16" & < "v0.17"}
             "virtual_dom" {>= "v0.16" & < "v0.17"}
             "base64" {>= "3.4.0"}
             "cohttp-async" {>= "2.5.7" & < "3.0.0" | >= "5.1.1" & < "6.0.0"}
             "dune" {>= "2.0.0"}
             "gen_js_api" {>= "1.0.8"}
             "js_of_ocaml" {>= "5.1.1"}
             "js_of_ocaml-ppx" {>= "5.1.1"}
             "ocaml-embed-file" {>= "v0.16" & < "v0.17"}
             "ppxlib" {>= "0.28.0"}
             "re" {>= "1.8.0"}
             "uri" {>= "3.0.0"}
synopsis     A library for building dynamic webapps, using Js_of_ocaml
description  Bonsai is a library for building reusable UI components inside an
                  Incremental-style UI framework such as Incr_dom or React.

[nix-shell:~]$ opam install bonsai
[NOTE] External dependency handling not supported for OS family 'nixos'.
       You can disable this check using 'opam option --global depext=false'
The following actions will be performed:
  ∗ install   patience_diff            v0.15.0  [required by patdiff]
  ∗ install   conf-libpcre             1        [required by pcre]
  ∗ install   async_ssl                v0.15.0  [required by cohttp_async_websocket]
  ↻ recompile ocaml-options-vanilla    1        [upstream or system changes]
  ∗ install   ocaml-embed-file         v0.15.0  [required by bonsai]
  ↻ recompile ocaml-secondary-compiler 4.08.1-1 [upstream or system changes]
  ∗ install   cryptokit                1.18     [required by async_websocket]
  ∗ install   async_extra              v0.15.0  [required by bonsai]
  ∗ install   conf-which               1        [required by conf-autoconf]
  ∗ install   ipaddr-sexp              5.5.0    [required by conduit-async]
  ∗ install   cohttp                   5.1.0    [required by cohttp_async_websocket]
  ∗ install   pcre                     7.5.0    [required by patdiff]
  ∗ install   async_websocket          v0.15.0  [required by cohttp_async_websocket]
  ∗ install   conf-autoconf            0.1      [required by stdcompat]
  ∗ install   conduit                  6.2.0    [required by conduit-async]
  ∗ install   patdiff                  v0.15.0  [required by bonsai]
  ↻ recompile stdcompat                19       [upstream or system changes]
  ∗ install   conduit-async            6.2.0    [required by cohttp-async]
  ↻ recompile pyml                     20220905 [uses stdcompat]
  ∗ install   cohttp-async             5.1.0    [required by bonsai]
  ∗ install   cohttp_async_websocket   v0.15.0  [required by async_rpc_websocket]
  ∗ install   async_rpc_websocket      v0.15.0  [required by bonsai]
  ∗ install   bonsai                   v0.15.1
===== ∗ 19   ↻ 4 =====
Do you want to continue? [Y/n] 

docs would say

opam install bonsai.0.16.0

but that did not work.

Strangely enough, upgrading to ocaml 5.2.0 made bonsai 0.16.0 visible (even though bnosai 0.16.0 only depends on ocaml 4.14.0, as shown above).

Using an OCaml 4.14 install what does opam install bonsai.v0.16.0 do?

Why it didn’t pick v0.16.0, I expect it didn’t find an install solution for the compiler version you are using. Can you include the OCaml version you are using?

It’s currently “working” now, and given how fragile (had to also build zarith / libpcre, which turned out to require nixos deps) everything is, I’m hesitant to run any opam commands at the moment.

This does not work because jane street packages have a v in their dependencies, so the correct command would be

opam install bonsai.v0.16.0

A reason opam may have not picked this version is that there could be other pre-installed packages in your switch which are incompatible with some of the dependencies of the new version of bonsai.

If you don’t want to mess around with the main switch, you can create local opam switches in your package folders. You can do that with

opam switch create . 4.14.1 --deps-only

See e.g. opam - new opam features: local switches for more information