Skip to content

ocamlbuild -where is not relocatable #326

@gridbugs

Description

@gridbugs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions