-
Notifications
You must be signed in to change notification settings - Fork 83
Description
ocamlbuild -where always returns the value of the $OCAMLBUILD_LIBDIR makefile variable set during build time. This means that if a pre-compiled instance of ocamlbuild is ever relocated, ocamlbuild -where will return the wrong result.
Practically, this causes problems for dune package management. Dune builds opam packages by running their build and install commands in a transient sandbox, after which all installed artifacts are moved into a shared opam-like filesystem and the sandbox is deleted. This results in errors like:
Warning: Won't be able to compile a native plugin
Failure: Cannot find "ocamlbuild.cmo" in ocamlbuild -where directory.
...because the directory returned by ocamlbuild -where was inside the (now deleted) build sandbox. (possibly related: #321)
My plan for addressing this is to implement ocamlbuild -where by locating the library directory relative to the path to the ocamlbuild executable (by means of Sys.executable_name), possibly keeping the current behaviour as a fallback.
See also: ocaml/dune#10290