Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to guess correct libdir from current exe #327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gridbugs
Copy link

@gridbugs gridbugs commented Apr 3, 2024

In cases where the libdir computed by ocamlbuild -where doesn't contain the expected ocamlbuild library files, attempt to guess an alternative libdir relative to the currently running executable's path (using Sys.executable_name). If the resulting libdir does contain the expected ocamlbuild library files then a warning is printed and the guessed libdir is used.

The motivation for this change is to allow the ocamlbuild (opam) package to be built by dune's package management features. Dune builds opam packages by executing their build and install commands in a temporary sandbox environment, and then copying the resulting artifacts to a final installation path. This creates a problem for ocamlbuild as the OCAMLBUILD_LIBDIR variable set at build time will be a path inside the temporary sandbox. That path is then used to compute the value printed by ocamlbuild -where which consequently reports a non-existant path.

This is an attempt to satisfy dune's constraint that a package's installed files must work after copying them out of their original install location.

We discussed this a little in #326. This is intended to fix this issue: ocaml/dune#10290.

In cases where the libdir computed by `ocamlbuild -where` doesn't
contain the expected ocamlbuild library files, attempt to guess an
alternative libdir relative to the currently running executable's path
(using `Sys.executable_name`). If the resulting libdir does contain the
expected ocamlbuild library files then a warning is printed and the
guessed libdir is used.

The motivation for this change is to allow the ocamlbuild (opam) package
to be built by dune's package management features. Dune builds opam
packages by executing their build and install commands in a temporary
sandbox environment, and then copying the resulting artifacts to a final
installation path. This creates a problem for ocamlbuild as the
`OCAMLBUILD_LIBDIR` variable set at build time will be a path inside the
temporary sandbox. That path is then used to compute the value printed
by `ocamlbuild -where` which consequently reports a non-existant path.

Signed-off-by: Stephen Sherratt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant