coc-extensions / coc-fsharp

coc.nvim integration for fsharp-language-server
Other
32 stars 3 forks source link

extension fails to load #25

Closed lc9er closed 2 years ago

lc9er commented 2 years ago

When I open a *.fs file, coc-fsharp attempts to update FSAC and fails with the error:

[coc.nvim] Error on activate extension coc-fsharp: Cannot read properties of undefined (reading 'browser_download_url)

I'm using Neovim 0.6.1, CoC 0.0.80-feb4169ac0, and coc-fsharp 0.2.7. Any ideas what's failing? I get the same results in WSL/Ubuntu 20.04.

rdipardo commented 2 years ago

Since version 0.50, FsAutoComplete is released as a NuGet package only: https://github.com/fsharp/FsAutoComplete/pull/875

coc-fsharp depends on the shape of the older API response, which provided a download link to the fsautocomplete.netcore.zip zipball:

This asset is the name property searched for by the LanguageServerProvider.fetchDownloadInfo method in the coc-utils module:

// coc-fsharp/node_modules/coc-utils/out/langserver.js, line 41
let matched_assets = api_result.assets.filter(x => x.name === platfile);

Because the zipball is no longer distributed, matched_assets will be undefined, and an unhandled TypeError prevents coc-nvim from loading the extension:

## versions

vim version: NVIM v0.6.1
node version: v14.19.0
coc.nvim version: 0.0.80-72aeffd7ab
coc.nvim directory: /home/rob/.config/nvim/plugins/coc.nvim
term: xterm-256color
platform: linux

## Log of coc.nvim

2022-03-01T18:55:50.155 INFO (pid:2288) [plugin] - coc.nvim initialized with node: v14.19.0 after 761ms
2022-03-01T18:55:50.456 ERROR (pid:2288) [extensions] - Error on active extension coc-fsharp: Cannot read property 'browser_download_url' of undefined TypeError: Cannot read property 'browser_download_url' of undefined
    at LanguageServerProvider.<anonymous> (/home/rob/.config/coc/extensions/node_modules/coc-fsharp/node_modules/coc-utils/out/langserver.js:46:44)
    at Generator.next (<anonymous>)
    at fulfilled (/home/rob/.config/coc/extensions/node_modules/coc-fsharp/node_modules/coc-utils/out/langserver.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

vim-lsp-settings has already implemented a workaround that could be usefully applied here.

lc9er commented 2 years ago

So I think I'm following: since the extension looks for an update (which is no longer there - in the expected format), it throws an error and the extension doesn't load.

Is there anyway to bypass this? I've installed fsautocomplete as a dotnet tool and coc-fsharp still won't load, even if I try to start it manually. Looks like the same problem occurs.

rdipardo commented 2 years ago

I'm afraid the extension will try to download the latest FSAC package regardless of whether you installed your own. Until it's properly fixed, you can hack around the problem like this:

// ${HOME}/.config/coc/extensions/node_modules/coc-fsharp/node_modules/coc-utils/out/langserver.js
// ~ line 37
    fetchDownloadInfo(platfile) {
        return __awaiter(this, void 0, void 0, function* () {
            if (this.repo.kind === "github") {
                let { repo: repo, channel: channel } = this.repo;
                //   BROKEN!
                //     |
                //     v
                //let api_url = `https://api.github.com/repos/${repo}/releases/${channel}`;
                //   WORKS
                //     |
                //     v
                let api_url = `https://api.github.com/repos/${repo}/releases/tags/0.49.6`;
                let api_result = yield utils_1.httpsGetJson(api_url);
                let matched_assets = api_result.assets.filter(x => x.name === platfile);
                return {
                    url: matched_assets[0].browser_download_url,
                    version: api_result.name,
                    id: api_result.id,
                    downloadedTime: Date.now()
                };
            }

This may have unwanted side-effects that I haven't noticed yet, but at least the server will be functional again.

## Log of coc.nvim
2022-03-02T18:20:39.909 INFO (pid:3638) [plugin] - coc.nvim initialized with node: v14.19.0 after 587ms
2022-03-02T18:20:40.460 INFO (pid:3638) [extension:coc-fsharp] - .NET SDK (reflecting any global.json):
2022-03-02T18:20:40.461 INFO (pid:3638) [extension:coc-fsharp] -  Version:   6.0.200
2022-03-02T18:20:40.463 INFO (pid:3638) [extension:coc-fsharp] -  Commit:    4c30de7899
2022-03-02T18:20:40.464 INFO (pid:3638) [extension:coc-fsharp] - 
2022-03-02T18:20:40.464 INFO (pid:3638) [extension:coc-fsharp] - Runtime Environment:
2022-03-02T18:20:40.465 INFO (pid:3638) [extension:coc-fsharp] -  OS Name:     bunsenlabs
2022-03-02T18:20:40.466 INFO (pid:3638) [extension:coc-fsharp] -  OS Version:  10.5
2022-03-02T18:20:40.466 INFO (pid:3638) [extension:coc-fsharp] -  OS Platform: Linux
2022-03-02T18:20:40.467 INFO (pid:3638) [extension:coc-fsharp] -  RID:         linux-x64
2022-03-02T18:20:40.468 INFO (pid:3638) [extension:coc-fsharp] -  Base Path:   /usr/share/dotnet/sdk/6.0.200/
2022-03-02T18:20:40.468 INFO (pid:3638) [extension:coc-fsharp] - 
2022-03-02T18:20:40.469 INFO (pid:3638) [extension:coc-fsharp] - Host (useful for support):
2022-03-02T18:20:40.469 INFO (pid:3638) [extension:coc-fsharp] -   Version: 6.0.2
2022-03-02T18:20:40.470 INFO (pid:3638) [extension:coc-fsharp] -   Commit:  839cdfb0ec
2022-03-02T18:20:40.471 INFO (pid:3638) [extension:coc-fsharp] - 
2022-03-02T18:20:40.471 INFO (pid:3638) [extension:coc-fsharp] - .NET SDKs installed:
2022-03-02T18:20:40.471 INFO (pid:3638) [extension:coc-fsharp] -   3.1.416 [/usr/share/dotnet/sdk]
2022-03-02T18:20:40.472 INFO (pid:3638) [extension:coc-fsharp] -   5.0.405 [/usr/share/dotnet/sdk]
2022-03-02T18:20:40.473 INFO (pid:3638) [extension:coc-fsharp] -   6.0.200 [/usr/share/dotnet/sdk]
2022-03-02T18:20:40.474 INFO (pid:3638) [extension:coc-fsharp] - 
2022-03-02T18:20:40.474 INFO (pid:3638) [extension:coc-fsharp] - .NET runtimes installed:
2022-03-02T18:20:40.475 INFO (pid:3638) [extension:coc-fsharp] -   Microsoft.AspNetCore.App 3.1.22 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2022-03-02T18:20:40.475 INFO (pid:3638) [extension:coc-fsharp] -   Microsoft.AspNetCore.App 5.0.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2022-03-02T18:20:40.475 INFO (pid:3638) [extension:coc-fsharp] -   Microsoft.AspNetCore.App 6.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
2022-03-02T18:20:40.475 INFO (pid:3638) [extension:coc-fsharp] -   Microsoft.NETCore.App 3.1.22 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2022-03-02T18:20:40.476 INFO (pid:3638) [extension:coc-fsharp] -   Microsoft.NETCore.App 5.0.14 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2022-03-02T18:20:40.476 INFO (pid:3638) [extension:coc-fsharp] -   Microsoft.NETCore.App 6.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
2022-03-02T18:20:40.476 INFO (pid:3638) [extension:coc-fsharp] - 
2022-03-02T18:20:40.476 INFO (pid:3638) [extension:coc-fsharp] - To install additional .NET runtimes or SDKs:
2022-03-02T18:20:40.477 INFO (pid:3638) [extension:coc-fsharp] -   https://aka.ms/dotnet-download
2022-03-02T18:20:40.477 INFO (pid:3638) [extension:coc-fsharp] - 
2022-03-02T18:20:40.478 WARN (pid:3638) [workspace] - workspace.createOutputChannel is deprecated, please use window.createOutputChannel instead. 
    at Function. (/home/rob/.config/coc/extensions/node_modules/coc-fsharp/out/client/fsac.js:77:61)
    at Generator.next ()
2022-03-02T18:20:40.523 INFO (pid:3638) [language-client-index] - Language server "fsharp" started with 3665
2022-03-02T18:20:45.644 INFO (pid:3638) [attach] - receive notification: showInfo []
lc9er commented 2 years ago

Thank you. This seems to work, at least partially. The extension now loads and I'm able to send lines to FSI. Other functionality, like autocomplete and definition/hover aren't working. But to be honest, it's been a few months since I've used the extension, so I don't remember if they were working in the first place.

Either way, this is a step in the right direction. Thank you for taking the time to help.

yatli commented 2 years ago

catching up 👀

yatli commented 2 years ago

don't want to lose auto-update. think I'm not going with dotnet install

yatli commented 2 years ago

fixed.