intellij-idearustintellij-pluginrust-cargo

IntelliJ Error When Importing Rust Project


I wanted to work on a Rust project and wanted to use IntelliJ and for this I installed Rust plugin:

https://plugins.jetbrains.com/plugin/8182-rust/docs/rust-quick-start.html

I then imported my project in IntelliJ, but somehow I'm not able to see the gutter menu next to my test case. I do not understand what I'm missing. I can see at the bottom in the Build window that there is something that fails.

Updating Workspace Info.

Execution failed (exit code 1).
/home/joesan/.cargo/bin/cargo metadata --verbose --format-version 1 --all-features
stdout : error: no override and no default toolchain set
error: backtrace:
error:    0: error_chain::backtrace::imp::InternalBacktrace::new
   1: rustup::config::Cfg::find_or_install_override_toolchain_or_default
   2: rustup_init::main
   3: std::rt::lang_start_internal::{{closure}}::{{closure}}
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/rt.rs:52
      std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/sys_common/backtrace.rs:130
   4: main
   5: __libc_start_main
   6: <unknown>


stderr : 

rustup show gave me the following:

Default host: x86_64-unknown-linux-gnu
rustup home:  /opt/softwares/rustup

stable-x86_64-unknown-linux-gnu (default)
rustc 1.46.0 (04488afe3 2020-08-24)

Any ideas how to get this fixed?


Solution

  • I fixed it by opening the Rust project in IntelliJ, navigate to File -> Settings -> Rust and then set the Standard library to the following:

    /opt/softwares/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib
    

    That is the location where I installed the Rust Toolchain. Somehow Intellij was not picking it up and I had to set it manually.