intellij-rust
intellij-rust copied to clipboard
standard library path not fully customizable when not using rustup
OS: Fedora 28
Rust 1.24 installed with dnf install cargo rust-src
- rust package installs
/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib
- rust-src package installs
/usr/lib/rustlib/src/rust/src
Giving that last path as "Standard library" did not work (message :
Cargo project update failed: invalid standard library: /usr/lib/rustlib/src/rust/src
However for some reason this works:
sudo ln -s /usr/lib/rustlib/src /usr/lib/rustlib/x86_64-unknown-linux-gnu/
then give /usr/lib/rustlib/x86_64-unknown-linux-gnu/src/rust/src
as "Standard library"
I should not have to modify system files (but maybe I missed another way?). Maybe current setup is tailored to rustup default path structure?
Final config for reference:
+1 for the request
I installed rust via homebrew for macOS. Had the same issue that I couldn't define the standard lib. looked around in the source code and found out why: https://github.com/intellij-rust/intellij-rust/blob/86396817d1d3e0965cc64a5879ab4689a6a7b067/src/main/kotlin/org/rust/cargo/project/workspace/StandardLibrary.kt#L37 . created a symlink as src and IntelliJ Rust is happy, though I am not but at least IDEA finally accepted the path.
In fedora 32 Rust works in IntelliJ without any hacks
Install "rust-src" package using
sudo dnf install rust-src
The Standard Library path mentioned in @mariuszs image will be available.
You can manually type it into the box in case it is not automatically discoverd.
Tested on fedora 32.
I experienced the same issue on Fedora 36 with both IntelliJ and CLion. What I did to "fix" the problem is nearly the same thing as the OP's solution except the directory in the third step is slightly different:
- Install the Rust sources if not already installed
sudo dnf install rust-src
- Create a symlink:
sudo ln -s /usr/lib/rustlib/src /usr/lib/rustlib/x86_64-unknown-linux-gnu/
- Specify the updated directory in the IDE (there is no "src/rust/src" anymore it's just "src/rust"):
/usr/lib/rustlib/x86_64-unknown-linux-gnu/src/rust
Afterwards, the message saying the IDEs can't attach the stdlib disappears.
Edit: Just a heads up for anyone reading, sometimes this temp-fix breaks depending on what I'm doing in the IDEs.