Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In IntelliJ IDEA on Gentoo, how do I attach the rust stdlib sources since gentoo does not use rustup?

Tags:

rust

gentoo

I am using IntelliJ's rust plugin (version 0.2.0.2114-182) with IDEA (2018.2.3).

There is a yellow bar at the top of my editor window that says "cannot attach stdlib sources automatically without rustup". This is not surprising since gentoo does not use rustup. It compiles rust from source.

There is an option to "attach manually", but I have no idea what directory it wants me to pick; or even what I should look for to figure out what the proper directory is; and I'm not even sure the gentoo ebuild created a directory with the necessary stdlib sources.

How can I provide the stdlib sources to the rust plugin in a way that is compatible with gentoo's package management system? It seems like answers to How to provide standard library sources for IntelliJ IDEA's Rust project? bypass gentoo's ebuilds and might cause the accumulation of cruft over time.

like image 227
Mutant Bob Avatar asked Sep 05 '19 14:09

Mutant Bob


People also ask

Does IntelliJ support rust?

Rust is supported in CLion via the IntelliJ Rust plugin, compatible with all IntelliJ-based IDEs. The plugin provides Rust language engine with a set of code insight features, Cargo support, and debugger functionality (in CLion and IntelliJ IDEA Ultimate).

Where is rust standard library installed?

The source for Rust's standard library can be obtained by running rustup component add rust-src . It will be downloaded to the <toolchain root>/lib/rustlib/src/rust directory of the current toolchain.


1 Answers

The dev-lang/rust Gentoo package has an rls use-flag (standing for Rust Language Server), which has a side-effect of installing Rust sources to /usr/lib/rustlib/src:

$ equery files dev-lang/rust | grep lib.rs
/usr/lib/rustlib/src/rust/src/libcore/lib.rs
/usr/lib/rustlib/src/rust/src/libstd/lib.rs
(...)

The solution is therefore to enable the rls use-flag and then point Intellij IDEA to /usr/lib/rustlib/src/rust/src:

Pointing Intellij IDEA Rust Standard library to /usr/lib/rustlib/src/rust/src

I believe this is a more idiomatic solution on Gentoo than to bypass portage and/or use rustup.

Note that dev-lang/rust-bin package currently does not have the rls use-flag and I haven't found a way to install Rust lib sources with it.

Contributions regarding dev-lang/rust use-flags (and their docs) in Gentoo would be probably appreciated.

like image 191
Matěj Laitl Avatar answered Oct 19 '22 09:10

Matěj Laitl