purescript-language-server icon indicating copy to clipboard operation
purescript-language-server copied to clipboard

Report externs version mismatch

Open nwolverson opened this issue 4 years ago • 8 comments

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

  • Project is not built - we try to detect this and offer the build command as an action
  • Compiler version changed (externs version mismatch)

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.

nwolverson avatar May 12 '21 11:05 nwolverson

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

wclr avatar Jun 15 '21 09:06 wclr

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

nwolverson avatar Jun 15 '21 10:06 nwolverson

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.

CGenie avatar Jun 29 '21 04:06 CGenie

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.

nwolverson avatar Jun 29 '21 07:06 nwolverson

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

wclr avatar Jun 29 '21 07:06 wclr

@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

nwolverson avatar Jun 29 '21 08:06 nwolverson

@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.

wclr avatar Jul 07 '21 17:07 wclr

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).

nwolverson avatar Nov 24 '21 21:11 nwolverson