Setup Clion to WSL Rust Follow
How do I setup the CLion Rust pluggin to use WSL (Ubuntu) Rust instead of Windows Rust (I have both installed). I have CLion setup to use WSL for C/C++ and that all works but when I try to point CLion to the location where WSL install GNU Cargo it says it can't find Cargo (even though I'm looking at it in an Explorer window).
Please sign in to leave a comment.
Using the Rust plugin with a toolchain in WSL is not supported yet. Please follow https://github.com/intellij-rust/intellij-rust/issues/1171.
Anna Falevskaya Thanks for the reply. What is the supported debug path for Windows then? The doc for IntelliJ-Rust shows someone setting up a Mac. Is it Cygwin, mingw, mingw64...? And is there any doc for doing the setup on Windows?
You can set either Cygwin or MinGW as your working environment. Here is a detailed blog post about debugging Rust Code in CLion: https://blog.jetbrains.com/clion/2019/10/debugging-rust-code-in-clion/.
Using Windows CLion to work on linux/GNU rust projects under WSL now works (at least for me).
I'm adding this comment as this is the top search result in google when looking for "clion wsl rust".
These instructions are for CLion 2021.2.1, from this change-log : https://intellij-rust.github.io/2021/06/07/changelog-148.html
Basically, just turn on the experimental option `org.rust.wsl` (you can search actions for 'experimental features" to find the list of options).
You need to install rust in wsl, like any Linux distro.
Then just change up your rust toolchain location (setting->Languages & Frameworks->Rust) to point to your WSL toolchain. It should be someplace like: \\wls$\Ubuntu\home\user-name\.cargo\bin` . The standard library path should auto-update if you've set the toolchain root correctly.
That's about it.
You know it's working when you run something and the first cmd in the output window is something like `C:\Windows\system32\wsl.exe`
Now you can leave all your projects inside \\$wsl and use all the standard linux/GNU tools and libraries. You can even delete/remove your windows rust install.