Can't open libraries which have been down by opam in VSCode

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.


7EALP0N{0531

But When I try to open Core or Base in the layle.ml , it through out an error like that :
)(I@)H~R806~6TP1ZQY5~1

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.

2 Likes

Thanks a lot !
But I got another error :
image

You need to install the package with opam install base core. And compile your project with dune build. It should solve your issue.

1 Like

Actually , I have installed that , and I did use dune build :
URKEV7W1C2FN8DD16MQTS

Have you read Getting Started and FAQ sections of the README? Those can help

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.

2 Likes

Thank you !
I have try to Restart Language Server , but that didn’t work .
And When I try to use:

dune build [name] --watch

I got an error that:

Please install inotifywait to enable watch mode.

Could you tell me how to install inotifywait ?

But when I use build exec to run the simple test , it can run and print successfuly:
image

image

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.

I try to install that in Ubuntu , opam 4.10.0,
but it always says that there is no package found :hot_face:

apt install inotify-tools not opam
edit: maybe sudo