ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.6k stars 396 forks source link

action plugin: trying to read empty / non-existing directory raises #4445

Open anmonteiro opened 3 years ago

anmonteiro commented 3 years ago

First of all, apologies for not following the issue template. This is not necessarily a bug, I'm just trying to understand what the right behavior should be.

Right now, when trying to call read_directory_with_glob on a directory that either:

raises an error (in my case: read_directory: No such file or directory).

Going through the source code, I realized there's a TODO around this behavior.

I'm not sure what the right behavior would be here, so I'd like to get the discussion started.

Happy to take a stab at fixing this if we decide it does need fixing.

aalekseyev commented 3 years ago

I think the behavior (1) that makes the most here is so that dune creates the requested directory before calling the action if such directory exists in the dune's model of the build directory. (usually this means the directory exists in the source tree)

A simpler and almost-good-enough behavior (2) is to simply make read_directory succeed producing an empty list if the directory is missing. If in addition we make dune fail when a directory is requested that's trully-missing then I think that's pretty much indistinguishable from (1).

I'm afraid the action plugin is not high on dune priorities right now, so it probably won't get much dev time. So I vote for the solution (2) which seems good enough and easier to implement and review. (I tend to think of the mkdir side-effect in (1) as scary as side-effects are generally hard to think about in the context of incremental lazy computation graph)