-
Notifications
You must be signed in to change notification settings - Fork 470
Add support for DUNE_ROOT environment variable #12399
Description
Desired Behavior
Please add support for a generic DUNE_ROOT env var, similar to passing --root in the command line.
Rationale
Sometimes Dune guesses wrong the root.
E.g.:
| a/
|- dune-workspace
|- b/
|- dune-workspace
If I am in directory b/ and run dune build, it uses as root directory a/, and I have to instead use dune build --root . every time to work around that.
There are various reasons why one may not want to use the parent directory as root, like:
- if
a/dune(or another dune file ina/) is invalid/broken, runningdune buildinb/will fail, while runningdune build --root=.will succeed - evaluating all dune files in
a/might be slow, thus unnecessarily slowing buildingb/ - it can mess paths, e.g. we have a Makefile in
b/which refers to_build/<whatever>. Runningmake fooinb/will use different paths thus fail or have a wrong behavior
About supporting the env var in particular, it is because it is MUCH more convenient than passing a CLI parameter every time. Env vars can be set once and all subsequent commands will use it, and they interact nicely with many tools (e.g. nix-shell). Comparatively, it is rarely convenient or even possible to pass extra CLI parameters via other tools.
Note: my examples are about dune build but any dune command supporting --root should also support DUNE_ROOT env var.