Change OCAMLPATH value in dune

For teaching purposes, I would like to use a pre-compiled library (without the .ml files) inside a project.
This corresponds precisely to the issues mentioned here support linking against cmo/cmi without source · Issue #1665 · ocaml/dune · GitHub
running OCAMLPATH=<path/to/my/lib> dune … does exactly what I want. However, I wonder if its possible to simply run my dune command without setting the OCAMLPATH variable manually.

The last comment in the issue seems to suggest something like that but I am not a dune wizard.

You can set the OCAMLPATH variable in the dune-workspace file and it will be taken into account when you lunch dune:

;; dune-workspace

(context
 (default
  (paths
   (OCAMLPATH <path/to/my/lib>))))

Cheers,
Nicolas

it worked, thank you :smiley: