On Cygwin/MinGW/Opam2.2.1, I have installed core.v0.16.2 in a 5.1.0 switch
I can compile a program using the Core module.
However, vscode points an Unbound Core Module in my code. I have verified, vscode is set with the opam(5.1.0) Global switch. Note: when I try to set the switch on vscode, I have the Unable to read the current switch, but the proposed menu contains all my switches (default and 5.1.0).
I guess vscode use the 5.1.0 switch (ocaml-lsp-server is not installed in default), but ocaml-lsp-server fails to use Core.
With open Base instead of open Core, no error is displayed (excepted the Core function calls). base is only installed in the 5.1.0 switch.
Somehow, I experience similar errors in emacs with opam on Debian. Reloading file through M-x revert-buffer helps. Also, before reloading I make sure that dune build -w is running, and that the (libraries core) annotation is present in the dune file. I didn’t try to get to the bottom of this, but this approach seems to work for me. Also, without dune build, some errors of that nature (including the inability to locate Core) persist occasionally even after the buffer reversal.
My opam switch is one of 5.2.0 ones.
My guess: the observed behavior is highly likely generated by a merlin-type assistant running in background. If vscode uses something other than merlin, then perhaps it’s related to the build system curiosities at play.
Ok, had an (libraries base stdio) instead of (libraries core)… but curiously, dune managed to build! (libraries core), but also the dune build -w solved the issue.