BetterThanTomorrow / calva

Clojure & ClojureScript Interactive Programming for VS Code
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva
Other
1.67k stars 217 forks source link

LSP fails to start if set to 'nightly' and no internet connection #1891

Open skylize opened 2 years ago

skylize commented 2 years ago

When LSP version is set to 'nightly', Calva always downloads LSP. If there is no network connection, this leads to no LSP being installed, so the server cannot start.

Related issue that this behavior is frustrating when trying to develop Calva, because each refresh of the Debug instance of Code triggers a new download and install, which must complete before you can test many changes in the code.

Both of these can likely be solved at once by

  1. Querying for the version of the latest nightly
  2. If the version cannot be determined, assume that means a download will also fail, and bail out.
  3. Compare installed vs latest nightly version numbers before deciding to download.

Some partial legwork in this direction:

I found that the downloadClojureLsp function in src/download.ts links to .../releases/latest/download/${artifactName} which redirects to something like .../releases/download/2022.10.06-12.52.58-nightly/{artifactName}. So we should be able to initially follow that link with Node's built in https module instead of the one provided by follow-redirects, and parse the version from the returned redirect url.

PEZ commented 2 years ago

I think this is an edge case that I hesitate to allow to complicate the download code more than it already is.

Most people should be running with latest. Using nightly is nice way to help find and fix problems with clojure-lsp, even if it might come with some slight inconveniences.

These are some workarounds that I employ:

Also, if I am not needing clojure-lsp for debugging something, I most often let it download and disregard it, because Calva starts fine meanwhile.

skylize commented 2 years ago

Understand your reasoning. Would you consider a PR, or is this just dead in the water?