Installation and Debugging on Windows 8 and 10

Hi. I am a Senior SW engineer with a mainly Java background. I have no knowledge of the c++ toolchain.
I have been looking at alternatives to Java for some time now and have had some very positive success with GoLang.

I am now looking at Rust as it is growing in popularity and I really like the idea of a language that will scale without a Garbage Collector.
I am also a big fan of a conpiler that picks up on logic errors. This seems to be a big feature of Rust. The language docs are also very good

My Development tools are IntelliJ on Windows 8.1 (For work) and VSCode on Windows 10 or Linux (for every thing else). I also have WSL2 installed on Windows 10.

The Help I need is with installation. I have been looking at this for a few days and I still do not have a Windows 10 (non WLS2) VSCode I can use.

  1. The installation instructions require the installation of Windows build tools for the c++ compiler and refers to a MS page where none of the tools match the stated, required tool.
    Could somone please be very specific about the versions and tools required and update the installation docs.
    Also the installation of the MS build tools consumes somthing like 4.5 gig and takes ages to install, really am not a fan of this.
  2. I also found it confusing what tool to use 'rustup-init.exe' has several versions with different sizes from different places. Which is the latest.

I finaly got to the point where I could create a project with cargo and compile and run.

I know VSCode is nothing to do with Rust but the tools are critical.

  1. Which version of VSCode! in the Rust Pluggin it says 1.8. The latest version of VSCode I can find is 1.40!
  2. Which pluggin (do I require both):
    Rust language interface for VSCode.
    Rust langusge support (rls)
  3. Do I go for the stable or nightly version. Do I go for GNU or the MSVC. There is no detailed explanation I could find.
  4. It finally loaded the rust tools but I cannot get Debug to work. I followed the instructions but they dont match the experience.
  5. I am currently getting a compile error in the VSCode terminal:
    thread 'main' panicked at 'No root path or URI', src\libcore\option.rs:1188:5
    note: run with RUST_BACKTRACE=1 environment variable to display a backtrace.
    [Error - 10:58:52] Connection to server got closed. Server will not be restarted.

What am I supposed to do with this?

I have tried various 'VSCode with Rust' web pages via Google but they either do not refer to the same versions of the code I am using or just assume everything works out of the box. This is NOT my experience.

So I am stuck. I cannot build, run or debug in VSCode which is very disapointing.

The installation guides seem to be out of date and the tools are in a mess.

There is a load of Rust specific terminology that I am not familier with and I am sure others are in the same boat.

What toolchain am I using, how do I find out. Do I use stable or nightly. My experience says stable. The tools say they work with nightly...

I havent got to the WSL install or VSCode on Linux yet. I assume to toolchain is simpler.

I also (for similar reasons) can not get IntelliJ on Windows 8.1 to run with debug! It wants paths I do not know!

I really believe Rust should be easier to install and integrate in to IDE's.

Do I really need experience with c++ toolchain to get Rust to build!

Sorry for the rant but I have a load of frustration to vent.

Please help.

Stuart

I too would love to know how to get the Rust Language Server running with VS Code on Win 10 with the WSL.

I presume I have the latest VSCode, it updates itself every now and then.

I have 'Remote WSL' and 'Rust (rls)' extesions installed intp VSCode.

I have Rust installed and working in Windows and in the WSL.

The upshot is that I have nicely syntax highlighted Rust in VS code but the RLS does not work. Whenever I open a Rust project I get a bunch of inscrutable errors popping up including "The rust language server crahsed x times in y minutes."

Every week or so I try and look at fixing this but with no joy so far. I have followed the instructions here:https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl as well as whatever I can find about the RLS. The latest of which is this discussion on the rust-lang github repo: "Cannot install rls" https://github.com/rust-lang/rls/issues/1011

There we find that the required components are not built with every rust nightly. But I can get it to work using stable.

Edit: I have a little spinner in the VSCode status bar that says "RLS starting". It spins forever.

I've started using Rust Analyzer instead. Seems to work quite nicely, including populating the Outline tree in VS Code - yay! Install from source is easy, and a git pull then cargo xtask install keeps you up to date. Suggest uninstall RLS first.

Debugging on Windows is a wreck though - too many variables are claimed to be optimized away, even in debug mode.

Thanks for the heads up on that. A quick scan of the github instructions indicates that I could likely waste a week trying to build that and getting to work. Perhaps I'll have a go at it one day.

I have never been one for using debuggers. Never felt the need for one. Not unless I have some problem I really cannot fathom, usually on an embedded system. But then I often found the using a debugger did not help much, problems can go away when you look for them!

I find even less need for a debugger with Rust. If the code compiles it will run without crashing. If the program gives a wrong result it's usually fairly obvious to realize ones mistake. Putting a few tests in place saves a lot of time futzing around with debuggers and is repeatable.

But I would like some of those nice red squiggles, auto-completion and other goodies an IDE can provide.

That was also my reason for not trying out rust-analyzer in the past. A few days ago I just tried it anyway and was surprised that it just worked. On Windows! I just installed nodejs (pretty quick), removed the existing Rust plugin from VSCode and then followed the short instructions in the rust-analyzer repo. After less than ten minutes I was done :slight_smile:

Hmm...tempting.

I was being timorous. You see I know nothing of Windows, having not really used it since I deleted Win 98 on discovering I could buy a RedHat boxed CD set in the local store. Only recently started using Win10 when the boss bought me an MS Surface Pro 4. That is only possible because of the WSL where I have all my compilers and other tools installed. I try to ignore the rest of Windows....except for VSCode which I'm now very much attached too.

I'll give Rust Analyzer a go when I get a free hour.

Thanks.

Dang, I git tempted to try rust-analyser. I follow the github instructions:

# clone the repo
$ git clone https://github.com/rust-analyzer/rust-analyzer && cd rust-analyzer

# install both the language server and VS Code extension
$ cargo xtask install

# alternatively, install only the server. Binary name is `ra_lsp_server`.
$ cargo xtask install --server

It fails with:

Error: install client

Caused by:
    Could not install the Visual Studio Code extension. Please make sure you have at least NodeJS 10.x together with the latest version of VS Code installed and try again.

Which is a useless message because I have:

$ node -v
v13.6.0
$ code -v
1.41.1
26076a4de974ead31f97692a0d32f90d735645c0
x64

Which as far as I can tell are the latest versions as required.

Looks like I can indeed waste a week on this.

Did you install rust-analyser in the WSL or in a DOS command box?

You probably didn't see my private message (I didn't want to further lengthen this thread with the rust-analyzer topic), but I did not use WSL.
But I also just found out that only 4 hours ago rust-analyzer started releasing binaries! https://github.com/rust-analyzer/rust-analyzer/releases So maybe you don't need to build it yourself after all.

I have now, thanks. You are right, if one installs rust-analyser on the Windows side from a DOS box as per the instruction here: https://github.com/rust-analyzer/rust-analyzer and runs VS Code from the Windows side, then rust-analyser works out of the box. I now have red squiggles and all kind of things popping up.

Seems it can also be installed from the WSL side but it complained about some path to std:: missing. Not to worry, all my code lives where Windows can see it.

A big thanks for the push in that direction.

I just noticed this morning, executable releases have been published to the rust-analyser github repo (including a .vsix VS Code extension), and I have successfully set them up on my windows machine. I guess they haven't announced anything yet, but I am super excited that there are finally binary executable releases!

edit: I am 33 minutes too late, just saw @dthul's comment :slight_smile:

I don't recall having to install build tools to get VSCode working. I'm sure it was just a case of downloading the installer from here: https://code.visualstudio.com/download

Just download and rustup-init from this download page https://www.rust-lang.org/tools/install

If you so the above today you will get the current latest VSCode 1.41. Which is working very well.

I never did have any luck getting the Rust Language Server (RLS) running. Just now I have the rust-analyzer extension installed and working in VSCode. See conversation in recent posts above.

That is the only Rust extension I have installed.

I have been using Rust nightly. I guess it depends on your requirements for stability and repeatabilty. I would not worry about GNU or MSVC.

Installing the Rust tool chain into WSL running Debian is as easy as running the 'curl' command on the Rust download page https://www.rust-lang.org/tools/install. That gets you 'rustup' installed which can then be used to install stable or nightly Rust and switch between them.

In my experience it's best to not install VSCode in the WSL. Just do a regular Windows install as above.

I really believe getting up and running with Rust is about the easiest of any language I have ever used that is not supplied as a package with the operating system. In Windows and in Linux under the WSL. It's hard to see how it could be much easier.

No.

I understand the frustration. Sounds to me as if you have been led astray by some wonky advice wherever it was you came across it. Happens to us all.

ZiCog. Thanks for the response. It seems I have struck a cord!

The issue with 'Windows build tools for the c++ compiler' is nothing to do with VSCode.

Having downloaded 'rustup-init.exe' and run it on a clean system, the output below is reported:

When you follow the link you are met with a confusion of tools and downloading Build Tools for Visual Studio 2019 resulted in a 4.5 gig of (junk) disk space, and a considerable amount of time, just to build a simple rust app.

Or you could install 'visualstudio' (the full fat IDE from MS). WHY. There is no explanation and if you know nothing about c++ (as I don't) this whole process seem irational and confusing.

Also 'visualstudio' is nothing to do with VSCode so the c++ compiler is not included.

Rustup does loads of downloads when it runs, could it down load a minimal c++ toolchain and make life sooo much simpler.

Output from ustup-init.exe

Rust Visual C++ prerequisites

Rust requires the Microsoft C++ build tools for Visual Studio 2013 or
later, but they don't seem to be installed.

The easiest way to acquire the build tools is by installing Microsoft
Visual C++ Build Tools 2019 which provides just the Visual C++ build
tools:

https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019

Please ensure the Windows 10 SDK and the English language pack components
are included when installing the Visual C++ Build Tools.

Alternately, you can install Visual Studio 2019, Visual Studio 2017,
Visual Studio 2015, or Visual Studio 2013 and during install select
the "C++ tools":

https://visualstudio.microsoft.com/downloads/

Install the C++ build tools before proceeding.

If you will be targeting the GNU ABI or otherwise know what you are
doing then it is fine to continue installation without the build
tools, but otherwise, install the C++ build tools before proceeding.

Continue? (Y/n)

ZiCog. Further to your reply

I now have a working system;

The required VSCode pluggin is the 'Rust Language Support (RLS)' Not to be confused with the 'Rust Language Server' (RLS) which is downloaded by VSCode once you click on a .rs file along with a host of other 'tools'. I assume there are VSCode only related and required by the pluggin.

I uninstalled the lot and started from scratch.

This gives you code insight, build, run etc, but NOT debugging. I googled this and found a working solution at:

https://www.forrestthewoods.com/blog/how-to-debug-rust-with-visual-studio-code/

I can now build run and debug Rust code (back to the book)

Again thanks for your input.

PS: The rest of this thread is talking about rust-analyser. What's that about! What does it do, how do they help.

The language may be the easiest thing to understand about rust!

Seems it is me that has been confused. I really don't recall having such troubles getting rustup installed.

Now I'm confused as to the difference between 'Rust Language Support (RLS)' and 'Rust Language Server (RLS)'. The former of which I have never heard of.

It's great you got further than I did. Not that I ever tried to get a debugger working.

rust-analyser at least gives me red squiggles on my syntax errors and useful popup info on methods etc. As IDE's do.

It's all a bonus to me. I'm an old time vim user. I always found IDE's a pain too get working properly.

Rust language support is a vscode plugin which interacts with the rust language server, which communicates things like types, traits, functions, etc. to the rust language support plugin. The plugin then provides prompts and (probably) allows certain highlighters to highlight code properly. As far as I know, rust-analyzer tells you where errors or warnings happen. Rust analyzer is essentially visualizing compiler output on your code, while rust language server is providing compiler metadata to you.

I'd still recommend IntelliJ Idea though; it's an excellent ide overall.

I installed IntelliJ just so that I can work with Scala and SpinaHDL.

I have Eclipse, as the heart of the Quartus dev tools for Verilog and Intel FPGAs

I have VSCode for C++ and Javascript.

I have qtcreator for working with Qt.

They all make me crazy with their huge size, complex installation, and general difficulty in doing anything with them.

VSCode makes me least crazy. At least it performs well as an editor.

Last I heard Rust support in IntelliJ was home made by JetBrains and did not understand the language very well. So I was loath to go down that path.

I might go back to vim.

The "Build Tools for Visual Studio 2019" are a bit bigger than strictly necessary, but Microsoft doesn't provide a more granular way to get what you need today. The parts Rust uses are the linker, a way to link to the C runtime, and a way to link to several Windows-specific libraries.

The full installation of Visual Studio includes all the same things- it's nice if you already have it, or already want it for something else, but the Build Tools is all you need if you're never going to use VS itself.

(Some more detail: yes, Rust does in fact depend on the C runtime despite not being C. There are a couple of reasons for this. First, it provides some simple functionality (e.g. math functions) that Rust has no reason to reimplement. Second, it's required for interoperating with C programs, which many Rust programs do.)

If you like, you can instead use the GNU-based Rust toolchain. This has no dependency on the Visual C++ toolchain, but in exchange has poor compatibility with other Windows software. This may or may not matter for your use case, but there's a reason it's not the default.

1 Like

Maybe a while ago; but IntelliJ Rust I've found to be better than RLS in my opinion. Also, while it's a somewhat slow ide, IntelliJ is a cross between a lightweight ide and a visual studio size ide.

It understands nearly everything in rust except for lifetime rules (IE it has no borrow checker) but it can handle generics of most sizes and complexities. It also updates nearly instantly based on your code as opposed to the approximate 10s to wait for RLS to reload. Overall, I'm very happy with it.

1 Like

I teach programming using Java, I can install java easily and my students are up and running with NetBeans or (for the more adventurous) VSCode. I only have to deal with the language.

I am also now using examples from GoLang. It's harder to install (on windows) which is my students preferred platform (they mainly use their own laptops) but it's managable.

I would love to teach using Rust. I believe it has lots to say about language design and function. It is very different and brings different concepts to the table. At the moment I can demonstrate but cannot set exercises that can be done on their laptops. The installation issues are a too much of an ask.

I would love for them all to use Linux but that is not possible at the moment.

fwiw, I do think the MS Build tools (which includes the MSVC compiler and linker, as mentioned above) is the biggest chunk of the install.
I got by for quite a while without real IDE support, and I didn't suffer too much, because the compiler error messages are well written and usually easy to understand. cargo check is your best friend.
I would also recommend IntelliJ IDEA for the IDE - I tried VScode, but couldn't get a workflow, and suffered from the RLS' slow response times. Maybe rust-analyzer has fixed that. Any of the IDEA-based IDEs will take the Rust plugin (IntelliJ has a free community edition), and I haven't had too many problems with it. It's been more responsive than RLS was for me. I still use the builtin terminal and run cargo check pretty often, though. I just find it more responsive, and it helps be separate the 'writing' and 'editing' portions of coding.