-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unbound module Stdlib in VS Code #30
Comments
Try the following in order and post your results in this ticket:
|
However, I would ideally like to have syntax highlighting for .ml files not part of any project and without using dune. I haven't needed to use dune thus far to compile and run my .ml files.
|
Thanks; I see a bug in that documentation now that we have a new version of dune. Let's do it again using
That new command creates a single-line file called |
Thank you, that does appear to work. Dune build now succeeds and syntax highlighting for helloworld2.ml seems to function properly (though I still need to manually instruct VS Code to convert helloworld2.ml from CRLF to LF to avoid an invalid character message). As I mentioned previously, though, is it possible to get syntax highlighting working without making these dune files each time? My instructor distributes .ml files (we have not discussed dune) and I'd like to be able to open them without the unbound module errors. My peers on Mac/Linux seem to have VS Code working without using dune (though they probably don't use Diskuv OCaml). |
Interesting ... I assume you are compiling by hand with I suspect your peers on Mac/Linux are using older "ocaml-lsp-server" (that is the OCaml tool that talks to VS Code) and they will eventually run into the same problem. Dune recently became the only officially supported way to get syntax highlighting. But you may be able to get some syntax highlighting if you don't already. Can you switch the "sandbox" in VS Code? That is:
Does that work? You will still see If you can get that far, I will ask you to open a ticket with the team behind "ocaml-lsp-server" (actually, it may be better if your instructor does). They may ask your instructor to provide some Merlin files if you aren't using Dune. |
Yep, we've only been manually compiling or sending lines to UTop. Unfortunately, your instructions just recreated the same situation as the original problem (I had already been using dkml instead of playground). As you can see in the screenshot I originally posted, the lack of Stdlib also causes all operators like + and < and even negative signs in front of integers to be treated like errors too, so it is rather unusual. Fortunately, I did fix the problem. I ran
Technically, the paths are correct, though Windows usually uses backslashes. I am not sure why the installer chose To troubleshoot, I tried creating the OCAMLLIB environment variable (which did not exist post-installation) and setting it to
After restarting VS Code, syntax highlighting worked as expected for all .ml files, regardless of dune, just as I was hoping for. I guess the question is, why did the original library path work for UTop and ocamlc but not for ocamllsp? Should the installer be setting the OCAMLLIB environment variable, or perhaps is it possible to change the default library path in the binary? I am not sure whether it was the slashes or the 8.3 filename that ended up fixing things. Also, how did creating and building a dune project fix the highlighting without this environment variable? Does it override the standard library path reported by EDIT: It looks like the slashes and 8.3 filenames are red herrings. The issue is fixed just by setting the environment variable to the standard_library_default path. It just seems ocamllsp is unable to find Stdlib if OCAMLLIB is unset. |
Clearly that is a bug with ocamllsp. You may want to file a ticket there. The reason why DOS 8.3 names are given is because many many opam packages do not work with spaces in the path (ex. I'll close this ticket in a couple days because this last issue doesn't belong in this queue. Thanks for the patience. |
I installed Diskuv OCaml 1.1.0_r2 a few days ago without issue. UTop, ocamlc, and ocamlopt all seem to work fine. I've installed the OCaml Platform extension for Visual Studio Code, and unchecked "Use OCaml Env" per the documentation, however I have a strange issue where it seems ocamllsp can't find the stdlib module. The code does run in UTop if I use Shift + Enter, it is just the syntax highlighting that is broken. A screenshot is attached.
The text was updated successfully, but these errors were encountered: