Has anyone run across an issue where the motoko language server won’t run and add errors and warnings to the “Problems” tab in VS Code?
When I start my current project from a clone it asks me what motoko file I want to debug and I select the project I’ve set up to reference all my other libraries in the project. In the output tab I get some messages that it can’t find the canister ids. I then start dfx and run dfx canister create --all. This creates the canister_id file in .dfx. Now when I try to manually re-start the service and select my project I get the Motoko LS initialized, but nothing shows up in the Output and nothing seems to show up in the Problems tab even though building the projects definitely shows warnings and errors.
I’d love to figure out what is going on, because having to manually build each time is a real pain.
I was able to load up the extension in vs code in debug mode, but after client.start(); gets called, I don’t know what to grab a hold of to inspect or watch to see what is happening. I’m guessing it does something with dfx _language-service, but when I try running that from the terminal with force tty it just kind of sits there…I don’t know how to poke it with a stick.
Looks like I need to call it with some json rpc calls? What is the port it operates on? What command would I send it to make it try to build a project and return back any errors/warnings? Maybe I can figure out where things are going wrong. dfx version 11.1
Downgrading my DFX version to 10.1 in my dfx.json file fixed this. Other devs are reporting that 11.0 seems to work, but 11.1 and 11.2 do not. @claudio@rvanasa
Oh interesting, did some Motoko last few days and also had no error detected in VS Code. Thought it was me since I am no VS code expert but, maybe not then.
I use dfx v0.11.2. That’s my project repo (if someone needs one to debug).
Which version of the VS Code extension are you using?
The VS Marketplace listing is over a year out of date (fixing this just became a top-priority ticket in our IT department, and we’re trying to resolve this as soon as possible).
A few days ago, we released v0.4.1 on GitHub, which includes a fallback language server for environments without a local dfx installation. You can try unchecking the “Legacy Dfx Support” setting (and then restarting the language server) in case this works as a short-term solution.
Let me know if you continue running into issues on the latest version, and I’ll do my best to replicate on my end so we can fix this for everyone.
Replicated in the papyrs/ic repository. Unchecking the “Motoko: Legacy Dfx Support” option in the VS Code settings works for me, and I’ll see if there’s a way to quickly fix the issue with the OCaml language server.
It’s possible that the issue is related to dfx being unable to resolve canister:* import aliases, which is causing some sort of unhandled error in the OCaml LSP.
A few additional debugging questions:
Does running dfx deploy (and then restarting the OCaml language server) change anything?
What happens if you run vessel install --force base? This is a new feature, so if this works but doesn’t fix the issue, there might be some regression that I’ll fix as soon as possible.
The Vessel resolution errors are expected, since the new LSP only supports the base library at the moment. I’m working on adding Vessel support right now, since this is something I can fix in the extension itself (compared to waiting for the next version of dfx).
Thanks for bearing with us. There’s a lot of technical debt to clean up in Vessel and the VS Code extension, so there might be a few bumps along the road as we bring these projects out of hibernation.
Hooray! Glad this worked as a short-term solution.
As a general announcement, the extension is now fully up-to-date on VS Marketplace! Feel free to replace the GitHub version so you can automatically receive the upcoming bugfixes / improvements for the new LSP.
Things are working much better now. The change now is that the language server seems to only evaluate open files. Before I had to specify which canister I wanted it to evaluate and then it would cascade and find issues with files even if I hadn’t opened them up.