When I try to init an ocaml file with dune by “dune init executable layle layle --libs core,base” , I think I can use the two libraries named core and base.
core (starting with a lowercase letter) is the name of the package. You should have open Core rather than syntactically incorrect open core. Core (with uppercase) is the name of the module defined in the package core.
Also, core includes base, so you shouldn’t need both.
When that happens to me it is usually because of either:
Caveat 1: Because of the note above, during active development of your project, we advise building your project with dune in a polling mode using the option --watch . This rebuilds your project whenever a file is changed in your project. For example, run dune build --watch --terminal-persistence=clear-on-rebuild in your VSCode integrated terminal.
or something else which is usually fixed by Command Palette in VSCode (Ctrl-Shift-P / Cmd-Shift-P) and then OCaml: Restart Language Server.
On MacOs it is fswatch but you should use your favorite linux/OS package manager to install inotify-tools on linux.
also dune in non watch mode does not need a watcher. But :
The dune build and dune runtest commands support a -w (or --watch) flag.
When it is passed, dune will perform the action as usual,
and then wait for file changes and rebuild (or rerun the tests).
This feature requires inotifywait or fswatch to be installed.