Recently I realized that formatting documents (editor.action.formatDocument) stopped working.
I narrowed it down to nightly-2018-11-21-x86_64-unknown-linux-gnu
Nightly from the day before seems to be working fine.
$ rustup default nightly-2018-11-20-x86_64-unknown-linux-gnu
info: using existing install for 'nightly-2018-11-20-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-2018-11-20-x86_64-unknown-linux-gnu'
nightly-2018-11-20-x86_64-unknown-linux-gnu unchanged - rustc 1.32.0-nightly (5aff30734 2018-11-19)
$ # restart vscode and formatting works fine
$ rustup default nightly-2018-11-21-x86_64-unknown-linux-gnu
info: using existing install for 'nightly-2018-11-21-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-2018-11-21-x86_64-unknown-linux-gnu'
nightly-2018-11-21-x86_64-unknown-linux-gnu unchanged - rustc 1.32.0-nightly (f1e2fa8f0 2018-11-20)
$ # restart vscode and formatting does not work anymore
md5-9e24d64b4bdbd8611a047b33ea54bd85
[Error - 2:20:53 AM] Request textDocument/formatting failed.
Message: Reformat failed to complete successfully
Code: -32603
md5-bfeb3f6056679ea74a10b80cbfdf1d96
{"message":"multiple input filenames provided","code":null,"level":"error","spans":[],"children":[],"rendered":"error: multiple input filenames provided\n\n"}
md5-a12abead2233ffe804504dd67849ca64
[Error - 2:27:09 AM] Starting client failed
Error: Error starting up rls.
at ClientWorkspace.<anonymous> (/data/.vscode/extensions/rust-lang.rust-0.5.0/out/src/extension.js:372:23)
at Generator.throw (<anonymous>)
at rejected (/data/.vscode/extensions/rust-lang.rust-0.5.0/out/src/extension.js:14:65)
at <anonymous>
md5-033b0508dacf6889bc395ef6801445fa
$ rustup --version
rustup 1.15.0 (f0a3d9a84 2018-11-27)
I experience the exact same behavior (lack of formatting, error code -32603, the extension asking to install RLS every time I start VS Code) on one of my devs machines. I don't know if it's related, but I can't use Ctrl+/ to toggle comment either (only on that PC).
Today I reinstalled rustup completely but nothing changed. I'm on nightly.
$ rustc --version
rustc 1.33.0-nightly (d22fa2d87 2019-01-08)
$ rls --version
rls-preview 1.31.6 (1a6361b 2019-01-04)
$ rustfmt --version
rustfmt 1.0.1-nightly (be13559 2018-12-10)
I get the same error on stable rust. :(
[Error - 3:41:35 PM] Request textDocument/formatting failed.
Message: Reformat failed to complete successfully
Code: -32603
$ rustc --version
rustc 1.32.0 (9fda7c223 2019-01-16)
Same problem here:
rustc 1.32.0 (9fda7c223 2019-01-16)
rls-preview 1.31.6 (bfa1371 2018-12-07)
Ping @nrc @Xanewok can one of you take a look, please? :)
I'd like to report that updating to today's nightly 2019-02-21 solved all the issues.
[FYI] Following components are installed:
$ rustup component list | grep '('
cargo-x86_64-unknown-linux-gnu (default)
clippy-x86_64-unknown-linux-gnu (installed)
rls-x86_64-unknown-linux-gnu (installed)
rust-analysis-x86_64-unknown-linux-gnu (installed)
rust-docs-x86_64-unknown-linux-gnu (default)
rust-src (installed)
rust-std-x86_64-unknown-linux-gnu (default)
rust-std-x86_64-unknown-linux-musl (installed)
rustc-x86_64-unknown-linux-gnu (default)
rustfmt-x86_64-unknown-linux-gnu (installed)
For anyone who came to this issue searching for this error message, you could try running rls directly with logging enabled to see the exact reason why reformatting is failed:
$ RUST_LOG=rls=debug rls --cli
...
> format src/xxx.rs
[2019-03-03T05:49:24Z WARN rls::actions::requests] Reformat failed: ambiguous edition for ``
{"jsonrpc":"2.0","error":{"code":-32603,"message":"Reformat failed to complete successfully"},"id":2}
then you would have something specific to search about. In my case, creating rustfmt.toml with edition = "2018" fixed the rls reformat error for me.
Interesting, I managed to get the same "ambiguous edition" error once. But most times it actually works fine from the command line. It however never works in VS Code. You can also use RUST_LOG=rls=debug code to get the rls debug output in the VS Code output window.
I'm not sure why the edition would be ambiguous though, it's defined in the Cargo.toml and nowhere else. Doesn't seem to be related to my project or the fact that I'm using workspaces. With a fresh project and no changes, it also doesn't work.
Creating a rustfmt.toml worked for me as well, but that's only a workaround.
@jsen- Can you please reopen this issue? Since it's still happening on stable (including the just released 1.33).
Had the same issue on ArchLinux
$ rls --version
rls-preview 1.33.0 (9f3c906 2019-01-20)
$ rustfmt --version
rustfmt 1.0.1-stable (be13559 2018-12-10)
$ rustup component list | grep '('
cargo-x86_64-unknown-linux-gnu (default)
rls-x86_64-unknown-linux-gnu (installed)
rust-analysis-x86_64-unknown-linux-gnu (installed)
rust-docs-x86_64-unknown-linux-gnu (default)
rust-src (installed)
rust-std-x86_64-unknown-linux-gnu (default)
rustc-x86_64-unknown-linux-gnu (default)
rustfmt-x86_64-unknown-linux-gnu (installed)
For anyone who came to this issue searching for this error message, you could try running rls directly with logging enabled to see the exact reason why reformatting is failed:
$ RUST_LOG=rls=debug rls --cli ... > format src/xxx.rs [2019-03-03T05:49:24Z WARN rls::actions::requests] Reformat failed: ambiguous edition for `` {"jsonrpc":"2.0","error":{"code":-32603,"message":"Reformat failed to complete successfully"},"id":2}then you would have something specific to search about. In my case, creating
rustfmt.tomlwithedition = "2018"fixed the rls reformat error for me.
Thanks for sharing solution :+1:
Most helpful comment
For anyone who came to this issue searching for this error message, you could try running rls directly with logging enabled to see the exact reason why reformatting is failed:
then you would have something specific to search about. In my case, creating
rustfmt.tomlwithedition = "2018"fixed the rls reformat error for me.