Try out Rust IDE support in Visual Studio Code


#21

Wow, great, and it works :smiley: Thank you very much. I was pretty sure there was no info about that in readme… but since it at least from 17 July, either I have installed it earlier, or didn’t pay much attention because at the time installation I had only main.rs anyway I’m really thankful for making it work for me again :wink:


#22

Really nice :slight_smile:
How is RLS doing the formatting ? I am just wondering because I get different results for the same file when I use rustfmt or format on save with the extension.


#23

Installed it, opened rustlings project and getting two errors: “Couldn’t start client Rust Language Server” and “Unexpected error initialising RLS - error running rustup”.

Please help.


#24

what version of rustup are you using?


#25
➜  ~  rustup --version
rustup 1.5.0 (92d0d1e9e 2017-06-24)

#26

Might it have something to do with PATH? I had to configure PATH for other extensions I’ve used, ended up having this section which is now commented out

// "rust.racerPath": "/Users/kb/.cargo/bin/racer",
// "rust.rustfmtPath": "/Users/kb/.cargo/bin/rustfmt",
// "rust.rustsymPath": "/Users/kb/.cargo/bin/rustsym",
// "rust.rustLangSrcPath": "/Users/kb/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src",

#27

I tried what you suggested but it didn’t actually help.
I’ve pasted the log into a gist here: https://gist.github.com/tanis2000/ce90baa791b1ee7d1a6b7662840db9e3

I hope it helps tracking down the problem. Right now it’s still not suggesting autocompletion nor jumping to definition.


#28

It uses rustfmt. It is possible you’re still using the legacy (stable-compatible) version of rustfmt? (RLS uses rustfmt-nightly). It might also be just that the RLS is pinned to a slightly more or less up to date version of rustfmt.


#29

You don’t need any paths set, you just need to be able to ‘see’ rustup from vscode (the version looks up to date to me, btw). If you can run rustup from the console, you could try running code from there too - you should then get exactly the same environment.


#30

I think you might be having issues because you have both a bin and lib crate in the project. Try setting rust.build_lib to true in your VSCode settings (this won’t be necessary in the future, hopefully).


#31

Didn’t help, unfortunately. Is there a way to debug this somehow to see why exactly it can’t start?

I just created an empty project via cargo new vscode-test --bin, fails the same way.


#32

I just wrote some advice on debugging - https://github.com/rust-lang-nursery/rls/blob/master/debugging.md Some of that might be useful.

So just to clarify, you can run rustup --version from the terminal, then from the same terminal run code, and it still gives the ‘can’t find rustup’ error?


#33

Is it possible to get rls nightly updated? It’s still sitting on rls 0.1.0-nightly (5d4bbd9 2017-08-07), see https://github.com/rust-lang-nursery/rls/compare/5d4bbd9...master.


#34

There’s a PR in the queue to do that, just waiting for it to land. Hopefully, that will be in today’s nightly, but it is cutting a bit fine, might be tomorrow.


#35

Ah, thanks. Could you link to that PR? I don’t even know what repo to look
in.


#36

Sure - https://github.com/rust-lang/rust/pull/44028


#37

Hm, I seem to have the analysis running continuously. And the crate’s not all that big. Will try to run with logs tomorrow, but I don’t know what to look for.


#38

… but after I turned on logging I can’t reproduce it and it seems to behave just fine.


#39

It seems like RLS performance issues are fixed (it was unusable before), thanks a lot! I’m using it with neovim, and works fast so far.


#40

Has anyone else found that you can’t install rls on nightly while it works on stable?

$ rustup component add rls-preview
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not contain component 'rls-preview' for target 'x86_64-unknown-linux-gnu'

$ rustup default stable           
info: using existing install for 'stable-x86_64-unknown-linux-gnu'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.21.0 (3b72af97e 2017-10-09)

$ rustup component add rls-preview
info: downloading component 'rls-preview'
  3.9 MiB /   3.9 MiB (100 %) 755.3 KiB/s ETA:   0 s                
info: installing component 'rls-preview'

EDIT: it appears this is because the component is called rust-analysis on nightly. Is this discrepancy deliberate?