Installing manually an opam-installable package

In attempting to install from the repo for yojson I see the opam file gives
[dune build @install -p yojson] as the build command which when entered at the shell runs fine.
The opam file isn’t explicit about the install command but there is a Makefile which
also has the very ordinary [dune install], which I guess opam automagically defaults to.
However, when performed manually at the shell, [dune install] gives the following:

Error: The following <package>.install are missing:
- _build/default/yojson-bench.install
Hint: try running: dune build [-p <pkg>] @install

yojson-bench is independent of the main yojson package yet here it is tripping up the install
of the latter.

Somehow an opam/dune coordinated installation succeeds in this, with no yojson-bench seen afterwards.

Does anyone know the reason for the difference between an opam/dune install and a manual one?

In a git checkout of the package (source tree), I suspect the following commands will build then install the package:

dune build @install
dune install

However, opam probably does not know that the package is installed if you do it this way.

without the -p argument everything installable gets included in the build and that means yojson-bench gets sucked in (which just causes earlier failure if the requisite deps are not there)
besides, that would be counter to the .opam file listed command.

Hi, I’ve never done it, but looking at Command-Line Interface — Dune documentation I would guess you just need dune install yojson.

from outside the opam build directory this indeed works.
from inside it needed dune install yojson -p yojson,
which I think must have to do with it being a local switch so with
a dune-project file above it.

curiously for the dune-configurator package, inside the opam build directory dune install dune-configurator worked while the with-“-p” version did not.

1 Like