Dune exec not same as running exe (WSL 2 on Windows)

Learning dune build system (GitHub). In doing the sum example from Real World OCaml (the instructions did not work as written but the code is valid) was able to build an executable. To avoid all of the potential problems I read about running OCaml on Windows natively ran using WSL 2.

dune build worked with no errors

Running the executable worked as expected

groot@Galaxy:~/.../sum$ ./_build/default/bin/sum.exe
1
2
3
94.5
Total: 100.5

However in reading Dune Quickstart learned of dune exec so ran

groot@Galaxy:~/.../sum$ dune exec sum
1
2
3
94.5
33659     1

The total line was not printed correctly.

Not looking to fix this at the moment but just passing along as feedback.

No idea what’s causing this, but it might be worth opening an issue in case the problem hasn’t been reported yet?

Here, dune exec sum is calling /usr/bin/sum (it found sum in your PATH) which is an unrelated binary. To execute bin/sum.exe, use dune exec bin/sum.exe (it would be possible to use dune exec sum if this binary was defined as a public executable, ie was part of an opam package which installed it as sum).

3 Likes

Thanks. :slightly_smiling_face:

I don’t have the environment that created the problem set up at the moment to work through as an exercise but when I do I will try to report back here. It could be days or more. I am way deep into another Problem with Prolog.