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 in a/) is invalid/broken, running dune build in b/ will fail, while running dune build --root=. will succeed
- evaluating all dune files in
a/ might be slow, thus unnecessarily slowing building b/
- it can mess paths, e.g. we have a Makefile in
b/ which refers to _build/<whatever>. Running make foo in b/ 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.
Desired Behavior
Please add support for a generic
DUNE_ROOTenv var, similar to passing--rootin the command line.Rationale
Sometimes Dune guesses wrong the root.
E.g.:
If I am in directory
b/and rundune build, it uses as root directorya/, and I have to instead usedune 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:
a/dune(or another dune file ina/) is invalid/broken, runningdune buildinb/will fail, while runningdune build --root=.will succeeda/might be slow, thus unnecessarily slowing buildingb/b/which refers to_build/<whatever>. Runningmake fooinb/will use different paths thus fail or have a wrong behaviorAbout 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 buildbut anydunecommand supporting--rootshould also supportDUNE_ROOTenv var.