Program opam not found in the tree or in PATH


I just made a opam update and upgrade. This upgraded dune from 2.9 to 3.03, and I now encounter the following error:

$ opam install iri
The following actions will be performed:
  - install iri 0.6.0

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved iri.0.6.0  (cached)
[ERROR] The compilation of iri.0.6.0 failed at "dune install -p iri --create-install-files iri".

#=== ERROR while compiling iri.0.6.0 ==========================================#
# context     2.1.2 | linux/x86_64 | ocaml-base-compiler.4.12.0 |
# path        /personal/guesdon/.opam/4.12.0/.opam-switch/build/iri.0.6.0
# command     /personal/guesdon/.opam/opam-init/hooks/ build dune install -p iri --create-install-files iri
# exit-code   1
# env-file    /personal/guesdon/.opam/log/iri-262849-0fa983.env
# output-file /personal/guesdon/.opam/log/iri-262849-0fa983.out
### output ###
# Error: Program opam not found in the tree or in PATH

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build iri 0.6.0
- No changes have been performed

But he PATH defined in /personal/guesdon/.opam/log/iri-262849-0fa983.env contains the directory where my opam binary is.

Any idea of what is wrong ?

I get the same error for other packages like js_of_ocaml-compiler and sha. But everything goes well for others, for example xmlm.

@bobot do you have any idea why opam is used in dune install?

I think it’s calling opam var prefix when no explicit --prefix is set.

Indeed it is for getting the prefix, this code path already needs some love for dune install wants opam or --prefix · Issue #5455 · ocaml/dune · GitHub.