Steps to reproduce:
Download and extract dune-bug.tar.gz.
Run
cd dune-bug
source script.sh
dune runtest
where script.sh changes the PATH variable to include the dir in the working directory.
Dune will attempt to run the cmake in dir, where cmake is a directory.
Doing this does work:
cd dune-bug/src
source script.sh
dune build lib.a
For comparison, running cmake in the Unix shell runs the cmake binary even when the cmake directory is in the search path.
(I'm using cmake because I encountered the bug when attempting to bind to a C++ program and couldn't think of any other examples, but you can replace the build steps with something more convenient and the bug will probably still exist.)