ocamlbuild icon indicating copy to clipboard operation
ocamlbuild copied to clipboard

MPR#6292: ocamlbuild -I does not understand paths that aren't relative descendants

Open damiendoligez opened this issue 8 years ago • 2 comments

PR transferred from https://caml.inria.fr/mantis/view.php?id=6292 [original reporter: @dsheets]

When running ocamlbuild with the -I option to include a directory for compilation unit reference, if the provided directory is not a relative descendant of the current working directory, then an error is produced e.g.:

Failure: Included or excluded directories must be implicit (not "../lib").

This restriction is probably no longer necessary and could be removed.

damiendoligez avatar Feb 24 '17 12:02 damiendoligez

Hi, I also ran into this. It is also failing for me if I provide fully explicit paths, even if they are a subdirectory of the current one. For instance ocamlbuild -I . might work but ocamlbuild -I $(pwd) fails.

Any chance of changing this?

mtzguido avatar Mar 31 '20 00:03 mtzguido

I gave an opinion on this mid-2018 in https://github.com/ocaml/ocamlbuild/pull/279#issuecomment-392315358 ; the fundamental reason why ocamlbuild insists on relative paths is that a path given by the user may be reinterpreted either at the invocation site, or within _build.

The only way to accept explicit paths that would make sense is to force them to only point to subdirectories of $(pwd), and the trim the $(pwd) prefix. I personally find this semantics a bit surprising / irregular, and I'm not sure it's a good idea to add such "magic" to the tool itself. (Given the moribund state of ocamlbuild usage and the ever-so-exciting of the rest of my work, I prefer to focus on development issues that are more critical.)

Note that it can be done rather easily from the caller side, at least if using bash: instead of ocamlbuild -I foo, just use path=foo; ocamlbuild -I ${path#$(pwd)/}, which strips the $(pwd)/ prefix from the $path variable.

gasche avatar Mar 31 '20 13:03 gasche