vscode-rust icon indicating copy to clipboard operation
vscode-rust copied to clipboard

RLS mode auto format fails with Code: -32601

Open klausi opened this issue 7 years ago • 11 comments

Version of VSCode: 1.12.1 Version of the extension: 0.3.14 OS: Ubuntu 16.04

Description: "Format Document" does not work in RLS mode.

Output of the "Rust logging" channel:

[Error - 11:47:41 PM] Request textDocument/rangeFormatting failed.
  Message: Reformat failed to complete successfully
  Code: -32601 

Maybe this is not supported yet in RLS mode? I also have "editor.formatOnSave": true in my settings and a rls.toml file with unstable_features = true but the Rust code is not automatically formatted on save.

klausi avatar May 15 '17 21:05 klausi

Set "rust.rls" to { "env": { "RUST_LOG": "rls=debug" }. After that post the output of the Rust Language Server output channel.

KalitaAlexey avatar May 16 '17 04:05 KalitaAlexey

Right now formatting support in RLS is behind the "unstable features" flags. Have you enabled this flag? See here how to configure RLS in your project. It should be as simple as adding a file called "rls.toml" with the following content:

unstable_features = true

Also, relevant cross-issues: rust-lang-nursery/rls#242 rust-lang-nursery/rls#3

Enet4 avatar May 16 '17 10:05 Enet4

RLS is so unstable as to be unusable. Going to racer for now. Really racer should be the default and RLS the cutting edge option.

DanielJoyce avatar May 16 '17 16:05 DanielJoyce

Attached is the output with the rls=debug option.

I don't see anything more verbose about the error in there.

Excerpt:

DEBUG:rls::actions: build "/home/klausi/workspace/rustnish"
DEBUG:rls::actions: reformat: format_input failed: has errors, summary = Summary { has_operational_errors: false, has_parsing_errors: false, has_formatting_errors: true, has_diff: false }
DEBUG:rls::server: response: "Content-Length: 101\r\n\r\n{\"jsonrpc\":\"2.0\",\"id\":3,\"error\":{\"code\":-32601,\"message\":\"Reformat failed to complete successfully\"}}"
[Error - 8:55:16 PM] Request textDocument/formatting failed.
  Message: Reformat failed to complete successfully
  Code: -32601 
DEBUG:rls::actions: build - Success

rls-debug.txt

klausi avatar May 16 '17 19:05 klausi

I switched back to legacy mode which mostly works in the meantime, described here: https://klausi.github.io/rustnish/2017/05/28/using-visual-studio-code-for-rust-on-ubuntu.html

klausi avatar May 30 '17 11:05 klausi

Still getting this error.. It actually does reformat, but complains too :/

Edit: it could be that it throws this error when rustfmt succeeds, but throws warnings like line overflow? Edit: yup, confirmed that this is the case.

marcusklaas avatar Aug 17 '17 19:08 marcusklaas

I'm still getting this error.

nox avatar Jun 19 '19 17:06 nox

Just starting learning rust and the formatting code does not work on mac. It's 2017 issue and still happening in 2019, anyone already know the workaround? Thanks.

[Error - 11:44:26 AM] Request textDocument/formatting failed.
  Message: Reformat failed to complete successfully
  Code: -32603

iambudi avatar Jul 13 '19 04:07 iambudi

Right it is still unusable.

xtlsoft avatar Jul 15 '19 04:07 xtlsoft

This extension hasn't been updated in two years, please use rust-lang/rls-vscode.

Systemcluster avatar Jul 15 '19 08:07 Systemcluster

Right, but it still has some problems and I am using an extension called rust-assist which provides the functionalitites which rls-vscode has bugs.

xtlsoft avatar Jul 15 '19 23:07 xtlsoft