overturetool / vdm-vscode

Visual Studio Code extension for VDM language support
GNU General Public License v3.0
21 stars 6 forks source link

setlinks for Windows user #175

Closed leouk closed 1 year ago

leouk commented 2 years ago

Nick, I showed the setlinks trick for getting uptodate jars on VSCode, but he's using Windows. And he's getting this error: image

The links looked "right" to me as in:

image

and also, we tried to test all was well by running java directly with the link as:

image

But no luck. Any suggestion what might be going wrong here?

nickbattle commented 2 years ago

Hmmm. Yeah, symlinks in Windows are [expletive]. They're not really transparent, so a non-MS program like Java does not correctly interpret them (ie. follow them). That's bound to be the problem, sorry; there's not much we can do.

With sensible OSs like Linux and MacOS, the symlink is transparent to all programs.

Given the trouble this has caused over the years, MS may have a better solution? Try googling this sort of thing?

AaronBuhagiar commented 2 years ago

Hi Nick,

Thanks for the response This particular issue does seem to stem from the symlinks. Attempting to run the jar directly from the maven target repository folder gives the same error as shown above.

image

That is not to say that the symlinks will not cause issues later on, but even manually copying the jar file has proven to be ineffective.

Any ideas on what might be causing the issue in this case?

nickbattle commented 2 years ago

Ah, if you just attempt to launch LSP itself without VDMJ (they're separate jars) then of course it will not be able to resolve symbols for VDMJ classes like Dialect. But I'm more worried about you saying that manually copying the files doesn't work. That absolutely should work(!!) - you mean copying jars from .m2/wherever to .vscode/extensions/overturetool...? That MUST work!?

Can you try to see the process line when VSCode launches the LSP server? I'm not sure what is available in Windows, but in Linux you'd see something like this from "ps":

> ps -ef | grep LSP
nick      2434  1875 33 14:57 ?        00:00:02 /usr/lib64/jvm/java/bin/java -Dlspx.plugins=plugins.ISAPluginSL -Dlsp.encoding=utf8 -Dvdmj.strict=true -cp /home/nick/.vscode/extensions/overturetool.vdm-vscode-1.3.3/resources/jars/vdmj/libs/*:/home/nick/.vscode/extensions/overturetool.vdm-vscode-1.3.3/resources/jars/plugins/vdm2isa-4.4.5-SNAPSHOT-220228.jar:/home/nick/.vscode/extensions/overturetool.vdm-vscode-1.3.3/resources/jars/vdmj/*: lsp.LSPServerSocket -vdmsl -lsp 42917 -dap 0

An invocation like this (rather than your example above) should "start", though obviously there will be no client to talk to it.

nickbattle commented 2 years ago

It looks like Windows has an (Administrator) command line command called mklink? It claims to be able to create hard links, which (maybe?) are hard enough. mklink /H hardlink_file.txt real_file.txt

Or is that what you were using anyway?

leouk commented 2 years ago

Yes, was going to suggest copying the jars Arron rather than symlink them for windows?

This will Mean you have to copy every time you build, but that could be part of the setlinks itself?

That is

''' git pull mvn clean install Various copy cmds ''' ?

AaronBuhagiar commented 2 years ago

Hi,

I have tried manually copying the jars from the .m2 folder and the problem still persists. I have tried mklink with /h and without to see if there was a difference between the symlinks or hardlinks but the problem persists. Could it be that there is something that needs to be configured with VSCode?

Executing vdmj through the cmd works fine: PS C:\Users\aray8\.vscode\extensions\overturetool.vdm-vscode-1.3.3\resources\jars\vdmj> java -jar .\vdmj-4.4.5-SNAPSHOT.jar -i -vdmsl "C:\Users\aray8\My Drive (abuh0018@gmail.com)\NCL\Demonstrator\CSC2304\Wordle\Wordle-4\wordle.vdmsl" Parsed 1 module in 0.067 secs. No syntax errors

image

It is only when using it through VSCode that there is an issue.

I have tried using a command similar to ps to see when LSP is executing in VSCode, however, the commands available for windows do not provide a transparent enough view to show what is going on. It only shows that VSCode is running.

nickbattle commented 2 years ago

OK, well mklink was worth a try.

Just to be clear... I assume that a freshly installed Overturetool extension works perfectly well? :-)

Another classic problem is when pathnames have spaces in them, though looking at the examples you gave above perhaps that is not the issue here.

There are various logs that VSCode produces (confusingly many) and we can additionally produce logs for the LSP server if you can get that going. There is an extension property which does this (and includes a link to the folder where the log will be created). Set this to "finest". Leo knows how to do it, if it's not obvious. Do you see anything interesting in any of these logs?

How do you know that VSCode is failing? What happens?

leouk commented 2 years ago

Hi Aaron

You have to go to settings filtered by vdm then log. You will see where log folder is as well as log levels etc. easier to show as Nick says.

Then the file will have any juicy bits Nick can decipher to know what's bad and why.

L

AaronBuhagiar commented 2 years ago

Yes, a new install was working fine. We ran into this issue when I tried updating the distribution of VDMJ to the development snapshot.

I have uninstalled the extension and deleted its files from my PC. Once I reinstalled it and ran the script to create the symbolic links, VSCode now seems to be working fine. I am still unsure what had caused this issue as the files in the extension folder seem identical to what I had before.

My only thought is that the issue came from the HP variant of the jar files. I think when I ran a script to create the symlinks for both standard and HP, there was an issue with there. Now that I have restored the files and only ran the commands for the standard VDM, all seems to be working fine.

Thanks for the help debugging this issue.

nickbattle commented 2 years ago

Ugh... well, at least it's working now, but we've missed the chance to sort out a problem that others might fall into :-(

One last thing. VSCode keeps logs for the past few sessions (you'll see dated folders). Would it be possible to ZIP up the last few, or as many as you've got, and paste them here? They're not very big. There might just be a clue somewhere there.

leouk commented 2 years ago

But does the script command works with the copied jar?

AaronBuhagiar commented 2 years ago

I apologise for that. Im afraid I didn't consider that by doing this we would be unable to find the root of the problem.

Please find attached the last 11 VSCode Session logs for your perusal logs.zip

AaronBuhagiar commented 2 years ago

The script now works with both copied and symlinks now.

I think the issue was coming from using the HP variant of vdmj as the jars for that are not included in the development branch and the script was designed to copy them as well. I think this caused the links to point to the wrong place. I am unsure whether I was using HP or not before the reinstall.

I have ensured that now I am using standard VDM and the links are pointing to the right jars and it seems to be working fine.

I hope this helps add some clarity to the issue

nickbattle commented 2 years ago

Thanks. There are quite a few instances of this:

Error: Could not find or load main class lsp.LSPServerSocket
Caused by: java.lang.ClassNotFoundException: lsp.LSPServerSocket

That's pretty fundamental! And it's consistent with the links not pointing to the right location. I can't see anything else from a quick skim of the logs. But at least we tried :-)

nickbattle commented 2 years ago

PS. don't forget to turn off the logging, or you'll slow everything down and fill up your disk :)

AaronBuhagiar commented 2 years ago

Thanks for all the help! (and for reminding me about the logging, I had already forgotten)

leouk commented 2 years ago

The script now works with both copied and symlinks now.

I think the issue was coming from using the HP variant of vdmj as the jars for that are not included in the development branch and the script was designed to copy them as well. I think this caused the links to point to the wrong place. I am unsure whether I was using HP or not before the reinstall.

I have ensured that now I am using standard VDM and the links are pointing to the right jars and it seems to be working fine.

I hope this helps add some clarity to the issue

Ah yes! I forgot to mention: you have to switch branches in VDMJ from development to HP and build both, then back to development, then setlinks! As development doesn't build the HP jars.

But unless you are with HP on, I presumed that it wouldn't affect you (i.e. there is an lsp-P and vdmj-p type jars).

nickbattle commented 1 year ago

Can we close this issue?

AaronBuhagiar commented 1 year ago

Hi Nick,

Yes this can be closed.