Sorry if this is already resolved, but I’ve been sifting through the internet and following tutorials with no results.
Reproducing the issue from zero:
I installed ocaml on the WSL(2) of Windows 11. I don’t understand a lot of the compiling, but I use Dune as a build system, and VSCode as IDE (running on the WSL).
I initialize a project on Ubuntu with: $ dune init proj Test
I open VSCode, and create two files FileA.ml
and FileB.ml
, with FileB depending on FileA and main.ml
being the executable.
main.ml
(default generated by Dune):
let () = print_endline "Hello, World!"
FileA.ml
:
let testA = true;;
FileB.ml
:
let testB = FileA.testA;;
And the dune
file contains:
(executable
(public_name Test)
(name main)
(libraries Test))
I can then run $ dune build
, which compiles fine (and even $ dune exec Test
).
However VSCode indicates the error on FileA.testA
:
I can also reinstall OCaml, restart the OCaml Language Server or change the dune
file to contain:
(executable
(public_name Test)
(name main)
(libraries Test)
(modules main FileA FileB))
and it always gives the same error.
Weird thing is that on my original project with a dozen files, this error only appears on some files even when there is nothing special in the dune files.
Thanks for your help.