nwolverson / purescript-language-server

MIT License
184 stars 41 forks source link

Report externs version mismatch #134

Open nwolverson opened 3 years ago

nwolverson commented 3 years ago

There are 2 main scenarios that lead to no useful type info being available:

We should detect the externs version mismatch and report this, also offering a rebuild action (If a rebuild is not enough to make things right, that's almost certainly a compiler issue).

To do this properly means adding something to the IDE protocol to return these errors as part of the JSON. A hacky solution of parsing the textual response would be able to detect this also.

wclr commented 3 years ago

It doesn't seem to handle the situation of purs version upgrade for me. I decided to upgrade from 0.14.0 to 0.14.2, so updated it locally in the project (using npm). addNpmPath is set true.

After vscode restart, I see the error about version mismatch, and infobox about need to rebuild.

In Purescript IDE output:

Info  - 2:23:29 PM] [Error] Version mismatch for the externs at: ...\output/Main\externs.cbor Expected: 0.14.2 Found: 0.14.0

[Info  - 2:23:29 PM] Error loading modules: Version mismatch for the externs at: ...\output/Main\externs.cbor Expected: 0.14.2 Found: 0.14.0

I click Build project, but it doesn't build correctly:

[Info  - 2:25:24 PM] Build complete
[Error - 2:25:24 PM] Couldn't reload modules, no ide server port
Built with 0 issues
Removing old diagnostics for: []
[Info  - 2:25:28 PM] [Info] cachedb was changed from: Just 2021-06-15 09:22:06.4522566 UTC, to: Just 2021-06-15 09:25:24.6287942 UTC @(main:Command.Ide app\Command\Ide.hs:199:25)

[Info  - 2:25:28 PM] [Error] Version mismatch for the externs at: ...\output/Main\externs.cbor Expected: 0.14.2 Found: 0.14.0

Have to run rm -rf output and Purescript: Build

nwolverson commented 3 years ago

The indication there is the build succeeded (which may be false) but the IDE server was not connected, can you attach a full log of startup.

Some supicous versions there indeed seem to indicate the build didn't happen

CGenie commented 3 years ago

I'm also getting a version mismatch in Emacs. I installed purels lsp server and am using lsp-mode:

[Error] Version mismatch for the externs at: xxx/output/A.B.C/externs.cbor Expected: 0.14.2 Found: 0.13.8

I'm using 0.14.2 in my project, I don't know why lsp mode picks 0.13.8.

nwolverson commented 3 years ago

That error message is telling you that actually you have built your project already with 0.13.8, but the lsp is using 0.14.2, you've read it backwards. In that case you should rebuild the project with 0.14.2. If the problem persists, clear output/ and do the same again, but that should not be necessary.

wclr commented 3 years ago

@nwolverson Probably it is worth extending the error description in this log as you explained?

nwolverson commented 3 years ago

@wclr feel free to raise an issue in the compiler repo if you think there is a better wording for this message. Here we're simply reporting the compiler-generated error. I don't want to complicate matters and make things fragile by parsing and rewording this message; personally I think it is concise and clearly labels the two versions, I'd have thought it more likely if it is not clear it is because it implies an understanding of what externs are, why they might be the wrong version, etc.

Perhaps we could also put a link to a troubleshooting section that would explain the message further and discuss resolutions - that is something that I've already thought should be added to the readme here. Maybe a few words about it in the error log, in general terms

wclr commented 3 years ago

@nwolverson did you manage to update purs version already built without manual deletion of existing output in your workflow? I didn't, always have to remove the output and then reload vscode window.

nwolverson commented 2 years ago

Per discussion on discord, it seems like this may be not initiating a rebuild correctly in the case where the compiler version has switched with some stale modules in output/ (where there is built results but the source has been moved/deleted).