theia icon indicating copy to clipboard operation
theia copied to clipboard

Support Rust-Analyzer Plugin

Open RodogInfinite opened this issue 4 years ago • 32 comments

Bug Description:

No rust-analyzer functionality. Appears in settings and commands, but doesn't work.

Terminal output:

ERROR [hosted-plugin: 32685] Activating extension 'rust-analyzer' failed: Error: Text Content Document Provider for scheme 'rust-analyzer' is already registered at WorkspaceExtImpl.registerTextDocumentContentProvider (/node_modules/@theia/plugin-ext/lib/plugin/workspace.js:274:19) at Object.registerTextDocumentContentProvider (/node_modules/@theia/plugin-ext/lib/plugin/plugin-context.js:488:37) at expandMacro (/plugins/rust-analyzer/extension/out/src/main.js:15024:58) at Ctx.registerCommand (/plugins/rust-analyzer/extension/out/src/main.js:15541:21) at tryActivate (/plugins/rust-analyzer/extension/out/src/main.js:17612:11) at async activate (/plugins/rust-analyzer/extension/out/src/main.js:17540:5)

Notifications: image

Steps to Reproduce:

  1. Add the following line to the theiaPlugins in the package.json "rust-analyzer":"https://github.com/rust-analyzer/rust-analyzer/releases/download/2020-11-16/rust-analyzer.vsix"
  • This is the latest version that will install without failing on VS Code version conflict. Example of the failure https://github.com/rust-analyzer/rust-analyzer/releases/download/2020-11-23/rust-analyzer.vsix notifies: image
  • The current fix is a bit hacky for this, see: https://github.com/eclipse-theia/theia/issues/8828
  1. Build and Start Theia
  2. Install Language server version 0.2.384 for rust-analyzer from notification prompt image

Additional Information

  • Operating System: Debian Buster
  • Theia Version: 1.12.0-next.8d5e12ac
  • Node Version: v12.14.1-linux-x64
  • Yarn Version: v1.22.10
  • "@theia/monaco" : "next" in package.json dependencies
  • Happens with or without "@theia/vscode-builtin-rust" : "next" in package.json dependencies

RodogInfinite avatar Feb 27 '21 19:02 RodogInfinite

I tried to use "rust-analyzer": "https://github.com/rust-analyzer/rust-analyzer/releases/download/2020-03-30/rust-analyzer.vsix" in the theiaPlugins section in the package.json because it was mentioned in https://github.com/eclipse-theia/theia/issues/7608 as giving the following error message, but still working: image

I also receive that error message, but do not get any functionality; however, my method of installing it is different.

For this particular version of the plugin I'm asked to download the following Language server: image

The terminal output is:

ERROR [hosted-plugin: 15765] Activating extension 'rust-analyzer' failed: Error: Text Content Document Provider for scheme 'rust-analyzer' is already registered at WorkspaceExtImpl.registerTextDocumentContentProvider (/node_modules/@theia/plugin-ext/lib/plugin/workspace.js:285:19) at Object.registerTextDocumentContentProvider (/node_modules/@theia/plugin-ext/lib/plugin/plugin-context.js:491:37) at expandMacro (/plugins/rust-analyzer/extension/out/main.js:13071:40) at Ctx.registerCommand (/plugins/rust-analyzer/extension/out/main.js:13783:21) at activate (/plugins/rust-analyzer/extension/out/main.js:17545:11)

Newest version with the same error:

The latest version of the plugin that doesn't give the double notification is "rust-analyzer": "https://github.com/rust-analyzer/rust-analyzer/releases/download/2020-06-29/rust-analyzer.vsix" with the same message displayed when theia is running:

Language server version is: image

Otherwise

After that version it looks like activate (/plugins/rust-analyzer/extension/out/main.js:17545:11) was changed to be asynchronously activated with tryActivate (/plugins/rust-analyzer/extension/out/src/main.js:17612:11) and async activate (/plugins/rust-analyzer/extension/out/src/main.js:17540:5) implemented as can be seen from the terminal outputs.

RodogInfinite avatar Mar 04 '21 22:03 RodogInfinite

Starting to compare the VSCode registerTextDocumentContentProvider and the Theia registerTextDocumentContentProvider though I don't have any TypeScript experience nor do I know how the plugin system works under the hood for Theia.

From the main.js in the extension starting at line 17546:

async function tryActivate(context) {
    var _a;
    // Register a "dumb" onEnter command for the case where server fails to
    // start.
    //
    // FIXME: refactor command registration code such that commands are
    // **always** registered, even if the server does not start. Use API like
    // this perhaps?
    //
    // ```TypeScript
    // registerCommand(
    //    factory: (Ctx) => ((Ctx) => any),
    //    fallback: () => any = () => vscode.window.showErrorMessage(
    //        "rust-analyzer is not available"
    //    ),
    // )

Registering the "dumb" onEnter seems to be causing the triple? register where the second notification "Cannot activate rust-analyzer: Text Content Document Provider for scheme 'rust-analyzer' already registered" is displayed.

RodogInfinite avatar Mar 06 '21 18:03 RodogInfinite

For a currently unknown reason, when I use "rust-analyzer": "https://open-vsx.org/api/matklad/rust-analyzer/0.2.497/file/matklad.rust-analyzer-0.2.497.vsix" in the package.json with theia start --vscode-api-version=1.53.0 I get syntax highlighting and the run and debug buttons in my main.rs file: image

However, neither of those buttons work. The same two error notifications occur as shown in the initial issue.

Status output from the Rust Analyzer: Status command after clicking the Run button:

workspaces: 11 packages loaded

analysis: 705 (7mb) files 0 (0b) index symbols 367 trees, 128 retained 12473 trees, 128 retained (macros) 175mb total

counts: all counts are zero

file info: crate: hello(CrateId(10)) deps: core=CrateId(1), alloc=CrateId(0), std=CrateId(6)

requests: 255 textDocument/codeLens 124ms 258 textDocument/hover 0ms

  • 3 textDocument/semanticTokens/full 0ms 4 textDocument/codeLens 1298ms 5 textDocument/hover 0ms 193 textDocument/hover 0ms 252 textDocument/foldingRange 0ms 250 textDocument/codeAction 142ms 251 textDocument/semanticTokens/full 142ms 253 textDocument/codeLens 0ms

After the 'run' button is clicked, the terminal outputs:

ERROR p</e.prototype.$executeCommand/</<@http://localhost:8080/bundle.js:147:346939 s/</<@http://localhost:8080/bundle.js:147:344908 s/<@http://localhost:8080/bundle.js:147:345013 r</<@http://localhost:8080/bundle.js:147:343925 r<@http://localhost:8080/bundle.js:147:343670 p</e.prototype.$executeCommand@http://localhost:8080/bundle.js:147:346810 m</e.prototype.doInvokeHandler@http://localhost:8080/bundle.js:8:408477 m</e.prototype.invokeHandler@http://localhost:8080/bundle.js:8:408210 m</e.prototype.receiveRequest@http://localhost:8080/bundle.js:8:407498 m</e.prototype.receiveOneMessage@http://localhost:8080/bundle.js:8:406985 e/this.multiplexor<@http://localhost:8080/bundle.js:8:404975 t/<@http://localhost:8080/bundle.js:8:408856 u</e.prototype[Symbol.iterator]/</<@http://localhost:8080/bundle.js:1:68438 u</e.prototype.invoke@http://localhost:8080/bundle.js:1:68657 d</e.prototype.fire@http://localhost:8080/bundle.js:1:70712 postMessage@http://localhost:8080/bundle.js:27:941944 d</e.prototype.onRequest/</<@http://localhost:8080/bundle.js:8:851189 s/</<@http://localhost:8080/bundle.js:8:849109 s/<@http://localhost:8080/bundle.js:8:849214 r</<@http://localhost:8080/bundle.js:8:848126 r<@http://localhost:8080/bundle.js:8:847871 d</e.prototype.onRequest@http://localhost:8080/bundle.js:8:851029 d</e.prototype.listen/<@http://localhost:8080/bundle.js:8:850671 q/a</</<@http://localhost:8080/bundle.js:1:265477 q/a</<@http://localhost:8080/bundle.js:1:266565 q/a<@http://localhost:8080/bundle.js:1:269193 f/<@http://localhost:8080/bundle.js:51:50393 f@http://localhost:8080/bundle.js:51:50508 s@http://localhost:8080/bundle.js:51:49866

When starting Theia, further up from the registering error in the terminal output is the following error output:

ERROR [535e032b-4cf4-48b3-b3c3-334e22be2216][matklad.rust-analyzer]: Failed to load 'configuration' contribution. e.fromPreferenceSchemaProperty@http://localhost:8080/bundle.js:79:82848 b</n.prototype.doSetSchema@http://localhost:8080/bundle.js:8:26639 b</n.prototype.setSchema@http://localhost:8080/bundle.js:8:28152 z/<@http://localhost:8080/bundle.js:22:582207 B@http://localhost:8080/bundle.js:22:581894 z@http://localhost:8080/bundle.js:22:582144 k</e.prototype.handleContributions@http://localhost:8080/bundle.js:22:582275 s@http://localhost:8080/bundle.js:1:760433 Q</e.prototype.loadContributions@http://localhost:8080/bundle.js:1:760915 Q</e.prototype.doLoad/</<@http://localhost:8080/bundle.js:1:758450 s/</<@http://localhost:8080/bundle.js:1:753022 s/<@http://localhost:8080/bundle.js:1:753127 a@http://localhost:8080/bundle.js:1:751841

I also tried the latest non-nightly release straight from the rust-analyzer github repo.

I used "rust-analyzer": "https://github.com/rust-analyzer/rust-analyzer/releases/download/2021-03-08/rust-analyzer.vsix" in the package.json with theia start --vscode-api-version=1.53.0 and got a new error notification: image

With the terminal output:

ERROR [hosted-plugin: 9169] Activating extension 'rust-analyzer' failed: TypeError: Class extends value undefined is not a constructor or null at /plugins/rust-analyzer/extension/out/src/main.js:12899:63 at createCommonjsModule (/plugins/rust-analyzer/extension/out/src/main.js:60:9) at Object. (/plugins/rust-analyzer/extension/out/src/main.js:11113:14) at Module._compile (internal/modules/cjs/loader.js:955:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10) at Module.load (internal/modules/cjs/loader.js:811:32) at Function.Module._load (internal/modules/cjs/loader.js:723:14) at Function.module._load (/node_modules/@theia/plugin-ext-vscode/lib/node/plugin-vscode-init.js:67:33) at Module.require (internal/modules/cjs/loader.js:848:19) at require (internal/modules/cjs/helpers.js:74:18)

Note: This open-vsx package is not searchable in the "Extensions: OPEN VSX REGISTRY" search

image

image It doesn't appear when scrolling further down nor with variations in the search terms

RodogInfinite avatar Mar 09 '21 20:03 RodogInfinite

Note: This open-vsx package is not searchable in the "Extensions: OPEN VSX REGISTRY" search

It doesn't appear when scrolling further down nor with variations in the search terms

@RodogInfinite just to mention, the oldest version on open-vsx (which is the open-source marketplace the extensions-view uses) for rust-analyzer is incompatible with the framework based on the api version. It uses a vscode.engines version of ^1.51.0 which is not supported by default by the framework and is the reason you do not see it while searching.

vince-fugnitto avatar Mar 10 '21 00:03 vince-fugnitto

@vince-fugnitto what would be the latest vscode.engines version that would need to be available to be searchable from within Theia? There's an ongoing effort in the rust-analyzer community to support open-vsx and it might be possible to get that version published, see: https://github.com/rust-analyzer/rust-analyzer/issues/7284

RodogInfinite avatar Mar 10 '21 02:03 RodogInfinite

@vince-fugnitto what would be the latest vscode.engines version that would need to be available to be searchable from within Theia?

@RodogInfinite the latest api version supported at the moment is 1.50.0:

https://github.com/eclipse-theia/theia/blob/8d5e12accfbd6bbe0cd720d3ebd151b700f4dc80/packages/plugin-ext-vscode/src/common/plugin-vscode-types.ts#L17

Anything targeting a range higher than 1.50.0 would not be present when searching due to incompatibility issues, and if manually installed would give a warning that it does not satisfy the requirements.

vince-fugnitto avatar Mar 10 '21 03:03 vince-fugnitto

@vince-fugnitto I have the same issue highlighted in the original comment ( Error: Text Content Document Provider for scheme 'rust-analyzer' is already registered)

Is it a know issue that is being worked on?

jeluard avatar Mar 16 '21 10:03 jeluard

@vince-fugnitto I have the same issue highlighted in the original comment ( Error: Text Content Document Provider for scheme 'rust-analyzer' is already registered)

Is it a know issue that is being worked on?

@jeluard feel free to pick up the issue :+1:

vince-fugnitto avatar Mar 16 '21 12:03 vince-fugnitto

@RodogInfinite @jeluard the documentation states the following, do you perhaps have both installed at the same time:

Provides support for rust-analyzer: novel LSP server for the Rust programming language.

Note the extension may cause conflicts with the official Rust extension. It is recommended to disable the Rust extension when using the rust-analyzer extension.

Note the project is in alpha status: it is already useful in practice, but can't be considered stable.

vince-fugnitto avatar Mar 16 '21 12:03 vince-fugnitto

@vince-fugnitto I do not, no.

Also note that I can see the following log twice when starting theia, not sure if expected:

root INFO [hosted-plugin: 24611] PLUGIN_HOST(24611): PluginManagerExtImpl/init()
root INFO [hosted-plugin: 24611] PLUGIN_HOST(24611): initializing([email protected] with /Users/julien/Documents/Projects/jeluard/theia/packages/plugin-ext-vscode/lib/node/plugin-vscode-init.js)
...

jeluard avatar Mar 16 '21 13:03 jeluard

@vince-fugnitto I also do not have the official Rust extension installed simultaneously with Rust-Analyzer. I can successfully get it running in VSCode with no issues

RodogInfinite avatar Mar 16 '21 13:03 RodogInfinite

Also note that I can see this error, unsure if relevant:

root ERROR [ad35fa06-5576-40ac-b57a-3ee6f24ac816][matklad.rust-analyzer]: Failed to load 'configuration' contribution. TypeError: Cannot create property 'scope' on boolean 'false'
    at Object.fromPreferenceSchemaProperty (http://localhost:3000/bundle.js:144722:31)
    at PreferenceSchemaProvider.../../packages/core/lib/browser/preferences/preference-contribution.js.PreferenceSchemaProvider.doSetSchema (http://localhost:3000/bundle.js:120041:82)
    at PreferenceSchemaProvider.../../packages/core/lib/browser/preferences/preference-contribution.js.PreferenceSchemaProvider.setSchema (http://localhost:3000/bundle.js:120122:28)
    at http://localhost:3000/56.bundle.js:7781:103
    at pushContribution (http://localhost:3000/56.bundle.js:7772:32)
    at _loop_1 (http://localhost:3000/56.bundle.js:7781:17)
    at PluginContributionHandler.push.../../packages/plugin-ext/lib/main/browser/plugin-contribution-handler.js.PluginContributionHandler.handleContributions (http://localhost:3000/56.bundle.js:7786:21)
    at _loop_2 (http://localhost:3000/56.bundle.js:969:63)
    at HostedPluginSupport.push.../../packages/plugin-ext/lib/hosted/browser/hosted-plugin.js.HostedPluginSupport.loadContributions (http://localhost:3000/56.bundle.js:990:17)
    at HostedPluginSupport.<anonymous> (http://localhost:3000/56.bundle.js:836:52)

jeluard avatar Mar 16 '21 13:03 jeluard

I am playing with Theia locally to see if it fits for a Rust project and i also do not have any other Rust extensions installed. I was not able to get rust-analyzer to work properly.

However, there is this line in package.json

"vscode-builtin-rust": "https://open-vsx.org/api/vscode/rust/1.45.1/file/vscode.rust-1.45.1.vsix",

Is that the official extension? do i need to remove it?

statictype avatar Mar 16 '21 13:03 statictype

However, there is this line in package.json "vscode-builtin-rust": "https://open-vsx.org/api/vscode/rust/1.45.1/file/vscode.rust-1.45.1.vsix", Is that the official extension? do i need to remove it?

@statictype that extension is the official rust builtin extension packaged with vscode, it related to the following:

  • https://github.com/microsoft/vscode/tree/5763d909d5f12fe19f215cbfdd29a91c0fa9208a/extensions/rust

It mainly contributes syntax-highlighting and snippets for the rust programming language.

vince-fugnitto avatar Mar 16 '21 13:03 vince-fugnitto

Despite the initial error, I do see that rust-analyzer works (potentially partially) it indexes, reports correct language-client/language-server communication, produces error markers, commands, preferences:

image

It may help narrow down your issues and investigations. I'm using the following version (which is API compatible):

  • https://github.com/rust-analyzer/rust-analyzer/releases/download/2020-11-16/rust-analyzer.vsix

vince-fugnitto avatar Mar 16 '21 14:03 vince-fugnitto

i'm not a rust developer myself, will have to check back with the team to see if it works entirely or partially. But, version 2020-11-16 seems to be working despite the initial errors. thanks, that really helped!

statictype avatar Mar 16 '21 16:03 statictype

@vince-fugnitto Indeed this version looks better, although there is still the original issue.

The other issue I encountered disappeared, it might be the one preventing the plugin to work at all.

jeluard avatar Mar 16 '21 16:03 jeluard

@vince-fugnitto Indeed this version looks better, although there is still the original issue.

The other issue I encountered disappeared, it might be the one preventing the plugin to work at all.

@jeluard the log is also present in vscode when investigating their devtools console:

image

For other versions of the extension I also get errors in vscode:

Activating extension 'matklad.rust-analyzer' failed: Failed to execute /home/evinfug/.config/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-linux --version.

Perhaps the extension itself has issues, and newer versions are not supported.

vince-fugnitto avatar Mar 16 '21 16:03 vince-fugnitto

@vince-fugnitto Nice find! I will follow up with the rust-analyzer team.

Somehow it's working ok for me on regular VSCode (on OSX). It might be more resilient to those issues?

jeluard avatar Mar 16 '21 16:03 jeluard

i'm not a rust developer myself, will have to check back with the team to see if it works entirely or partially. But, version 2020-11-16 seems to be working despite the initial errors. thanks, that really helped!

@statictype & @jeluard Does the run button appear for you, pictured below, and when you click it does it run as if you typed cargo run in the terminal? image

RodogInfinite avatar Mar 16 '21 16:03 RodogInfinite

@RodogInfinite Nice catch too! No it doesn't, and I get the following error:

ERROR Error: Command with id 'rust-analyzer.runSingle' is not registered.

jeluard avatar Mar 16 '21 16:03 jeluard

I'm unable to look at this deeply at the moment, but one thing to look for is which version first implemented the "run" and "debug" buttons. It may have appeared after the 2020-11-16 release. If no one else finds this before I'm able to look, I'll edit this post with the information when I locate it so as to reduce the number of comments.

RodogInfinite avatar Mar 16 '21 16:03 RodogInfinite

I meant that the buttons are there, but broken.

jeluard avatar Mar 16 '21 16:03 jeluard

So the official Rust plugin is tracking to merge with rust-analyzer (https://github.com/rust-lang/vscode-rust/issues/812, https://github.com/rust-analyzer/rust-analyzer/issues/4224) and when "rust-lang" is installed, rust-analyzer can be selected as the server from the settings; however, I don't get syntax highlighting nor the run | debug buttons when I select that option. I'm not sure how much will change by the time the merging is finalized, but it might be worth focusing on the official rust plugin to get the rust-analyzer functionality for the long-term

RodogInfinite avatar Mar 18 '21 19:03 RodogInfinite

With latest theia 1.12.0 and latest rust-analyzer I now get the following exception:

root ERROR [hosted-plugin: 11849] Activating extension 'rust-analyzer' failed: TypeError: Class extends value undefined is not a constructor or null
    at /Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/rust-analyzer/extension/out/src/main.js:12905:63
    at createCommonjsModule (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/rust-analyzer/extension/out/src/main.js:66:9)
    at Object.<anonymous> (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/rust-analyzer/extension/out/src/main.js:11119:14)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.module._load (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/node_modules/@theia/plugin-ext-vscode/lib/node/plugin-vscode-init.js:67:33)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
root ERROR [hosted-plugin: 11849] Activating extension 'Git (built-in)' failed: TypeError: n.window.registerFileDecorationProvider is not a function
    at new c (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/vscode-builtin-git/extension/dist/main.js:10:472547)
    at new t.GitDecorations (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/vscode-builtin-git/extension/dist/main.js:10:474947)
    at _ (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/vscode-builtin-git/extension/dist/main.js:1:79118)
    at async T (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/vscode-builtin-git/extension/dist/main.js:1:80865)
    at async t.activate (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/vscode-builtin-git/extension/dist/main.js:1:81734)

@vince-fugnitto maybe this rings a bell?

jeluard avatar Mar 26 '21 07:03 jeluard

FWIW the line triggering the error is:

class LSPCancellationError extends vscode__default['default'].CancellationError {

jeluard avatar Mar 26 '21 08:03 jeluard

More context: this has been introduced in VSCode 1.53.0: https://code.visualstudio.com/updates/v1_53#_adding-cancellationerror-type (defined here)

It looks like recent vscode-languageserver-node depend on it.

jeluard avatar Mar 26 '21 09:03 jeluard

Moving back to an older version, 489, I still get the infamous error:

root ERROR [hosted-plugin: 62023] Activating extension 'rust-analyzer' failed: Error: Text Content Document Provider for scheme 'rust-analyzer' is already registered
    at WorkspaceExtImpl.registerTextDocumentContentProvider (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/node_modules/@theia/plugin-ext/lib/plugin/workspace.js:285:19)
    at Object.registerTextDocumentContentProvider (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/node_modules/@theia/plugin-ext/lib/plugin/plugin-context.js:497:37)
    at viewHir (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/rust-analyzer/extension/out/src/main.js:18678:58)
    at Ctx.registerCommand (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/rust-analyzer/extension/out/src/main.js:19264:21)
    at tryActivate (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/rust-analyzer/extension/out/src/main.js:21340:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async activate (/Users/julien/Documents/Projects/paritytech/substrate-playground/templates/theia-playground/plugins/rust-analyzer/extension/out/src/main.js:21268:5)

Not sure how to debug that.

jeluard avatar Mar 26 '21 09:03 jeluard

When adding some traces, I can see that TextContentResourceResolver.prototype.registerContentProvider is called multiple times with the same scheme:

root INFO [3bd595d9-13df-4f5d-b139-c7d85011624c] Start of 18 plugins took: 694.3 ms
root INFO [hosted-plugin: 74351] Registering rust-analyzer-status [object Object]
root INFO [hosted-plugin: 74351] Registering rust-analyzer-memory [object Object]
root INFO [hosted-plugin: 74351] Registering rust-analyzer [object Object]
root INFO [hosted-plugin: 74351] Registering rust-analyzer [object Object]
root INFO [hosted-plugin: 74351] Registering rust-analyzer [object Object]
root INFO [4f0a4b9d-6ca9-457c-bb2c-e7dea13faa7b][matklad.rust-analyzer]: Started plugin.

Not clear why.

If I remove the check so that this function doesn't fail anymore, I then hit another error:

root ERROR [hosted-plugin: 74313] Promise rejection not handled in one second: Error: Text Content Resource Provider for scheme 'rust-analyzer' is already registered , reason: Error: Text Content Resource Provider for scheme 'rust-analyzer' is already registered
root ERROR [hosted-plugin: 74313] With stack trace: Error: Text Content Resource Provider for scheme 'rust-analyzer' is already registered
    at TextContentResourceResolver.push.../node_modules/@theia/plugin-ext/lib/main/browser/workspace-main.js.TextContentResourceResolver.registerContentProvider (http://localhost:3000/48.bundle.js:19659:19)
    at WorkspaceMainImpl.<anonymous> (http://localhost:3000/48.bundle.js:19606:39)
    at step (http://localhost:3000/48.bundle.js:19302:23)
    at Object.next (http://localhost:3000/48.bundle.js:19283:53)
    at http://localhost:3000/48.bundle.js:19277:71
    at new Promise (<anonymous>)
    at push.../node_modules/@theia/plugin-ext/lib/main/browser/workspace-main.js.__awaiter (http://localhost:3000/48.bundle.js:19273:12)
    at WorkspaceMainImpl.push.../node_modules/@theia/plugin-ext/lib/main/browser/workspace-main.js.WorkspaceMainImpl.$registerTextDocumentContentProvider (http://localhost:3000/48.bundle.js:19603:16)
    at RPCProtocolImpl.push.../node_modules/@theia/plugin-ext/lib/common/rpc-protocol.js.RPCProtocolImpl.doInvokeHandler (http://localhost:3000/39.bundle.js:1373:23)
    at RPCProtocolImpl.push.../node_modules/@theia/plugin-ext/lib/common/rpc-protocol.js.RPCProtocolImpl.invokeHandler (http://localhost:3000/39.bundle.js:1358:41)
Promise rejection not handled in one second: Error: Text Content Resource Provider for scheme 'rust-analyzer' is already registered , reason: Error: Text Content Resource Provider for scheme 'rust-analyzer' is already registered
With stack trace: Error: Text Content Resource Provider for scheme 'rust-analyzer' is already registered
    at TextContentResourceResolver.push.../node_modules/@theia/plugin-ext/lib/main/browser/workspace-main.js.TextContentResourceResolver.registerContentProvider (http://localhost:3000/48.bundle.js:19659:19)
    at WorkspaceMainImpl.<anonymous> (http://localhost:3000/48.bundle.js:19606:39)
    at step (http://localhost:3000/48.bundle.js:19302:23)
    at Object.next (http://localhost:3000/48.bundle.js:19283:53)
    at http://localhost:3000/48.bundle.js:19277:71
    at new Promise (<anonymous>)
    at push.../node_modules/@theia/plugin-ext/lib/main/browser/workspace-main.js.__awaiter (http://localhost:3000/48.bundle.js:19273:12)
    at WorkspaceMainImpl.push.../node_modules/@theia/plugin-ext/lib/main/browser/workspace-main.js.WorkspaceMainImpl.$registerTextDocumentContentProvider (http://localhost:3000/48.bundle.js:19603:16)
    at RPCProtocolImpl.push.../node_modules/@theia/plugin-ext/lib/common/rpc-protocol.js.RPCProtocolImpl.doInvokeHandler (http://localhost:3000/39.bundle.js:1373:23)
    at RPCProtocolImpl.push.../node_modules/@theia/plugin-ext/lib/common/rpc-protocol.js.RPCProtocolImpl.invokeHandler (http://localhost:3000/39.bundle.js:1358:41)

Also the following error happens sometimes:

root ERROR Error: Text Content Resource Provider for scheme 'rust-analyzer' has not been registered
    at TextContentResourceResolver.push.../node_modules/@theia/plugin-ext/lib/main/browser/workspace-main.js.TextContentResourceResolver.unregisterContentProvider (http://localhost:3000/48.bundle.js:19680:19)
    at Object.<anonymous> (http://localhost:3000/48.bundle.js:19607:112)
    at Object.disposable.dispose (http://localhost:3000/bundle.js:61019:13)
    at DisposableCollection.../node_modules/@theia/core/lib/common/disposable.js.DisposableCollection.dispose (http://localhost:3000/bundle.js:60996:40)
    at WorkspaceMainImpl.push.../node_modules/@theia/plugin-ext/lib/main/browser/workspace-main.js.WorkspaceMainImpl.dispose (http://localhost:3000/48.bundle.js:19376:24)
    at WorkspaceMainImpl.disposable.dispose (http://localhost:3000/bundle.js:61019:13)
    at DisposableCollection.../node_modules/@theia/core/lib/common/disposable.js.DisposableCollection.dispose (http://localhost:3000/bundle.js:60996:40)
    at RPCProtocolImpl.push.../node_modules/@theia/plugin-ext/lib/common/rpc-protocol.js.RPCProtocolImpl.dispose (http://localhost:3000/39.bundle.js:1211:24)
    at RPCProtocolImpl.disposable.dispose (http://localhost:3000/bundle.js:61019:13)
    at DisposableCollection.../node_modules/@theia/core/lib/common/disposable.js.DisposableCollection.dispose (http://localhost:3000/bundle.js:60996:40)

This implies TextContentResourceResolver.unregisterContentProvider is called before any registration is done, for some reason.

jeluard avatar Mar 26 '21 09:03 jeluard

@vince-fugnitto Where should I look if I want to add CancellationError ? A bit lost here :)

jeluard avatar Mar 26 '21 15:03 jeluard

@jeluard I haven't investigated the issue further or verified what changes might be necessary in the framework for it to work correctly.

The CancellationError was introduced in 1.53.0 and we are not currently at that API level. It's possible that you might get it to work but it will likely fail due to other compatibility errors. If interested in adding support you can take a look at previous pull-requests that introduce support for plugin APIs to get a better understanding of the plugin-system.

The API will need to be defined in theia.d.ts and you can inspire yourself from the implementation present in vscode which will be similar to changes required in the framework (in this case it looks like a simple extension of Error).

vince-fugnitto avatar Mar 29 '21 19:03 vince-fugnitto

Some current issues here:

  • [ ] Failed to activate because "Text Content Document Provider for scheme 'rust-analyzer' is already registered". The plugin registers several textContentDocumentProviders, and the registration is called multiple times for the rust-analyzer scheme. Probably should not be fatal, but investigation required to see whether the plugin is registering different providers or the same one repeatedly, and how VSCode handles analogous registrations.
  • [ ] When activating the vscode-lldb plugin for debugging, error is thrown for call to NetServer.listen with neither port nor path field. Problem occurs here where Theia's preference access system returns {} and VSCode's returns null. As a consequence, RPC is not started in VSCode but is in Theia.

colin-grant-work avatar Jul 05 '22 19:07 colin-grant-work