intellij-rust: IDEA cannot recognize Rust toolchain

The issue is related to the ticket from Zendesk Support.

Environment

  • IntelliJ Rust plugin version: 0.2.120.2202-201
  • Rust toolchain version: 1.43.0 (4fb7144ed 2020-04-20)
  • IDE name and version: IntelliJ IDEA 2020.1 (IU-201.6668.121)
  • Operating system: Windows 10 (10.0, amd64)

Problem description

IDEA cannot recognize Rust toolchain though the same toolchain is recognized fine on CLion 2020.1 with the same Rust plugin version installed.

Settings -> Language frameworks -> Rust

toolchain location : E:\dev\rust\cargo\bin
toolchain Version : NA
standard library : (blank)
download via rustup (clicking does nothing)

$ rustup show

Default host: i686-pc-windows-gnu
rustup home: E:\dev\rust

installed toolchains
--------------------

stable-i686-pc-windows-gnu
stable-i686-pc-windows-msvc
stable-x86_64-pc-windows-gnu

active toolchain
----------------

stable-i686-pc-windows-gnu (default)
rustc 1.43.0 (4fb7144ed 2020-04-20)

Annotation 2020-04-27 125218 rustplugins

idea.log

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 15
  • Comments: 36 (8 by maintainers)

Most upvoted comments

I had the same problem.

  1. Both IntelliJ and CLion are installed under the same admin user.
  2. checked with rustup -V, rustc -V, cargo -v and all 3 were installed. Unfortunately, I forgot to document what versions I was shown, but I think Clion showed rust version 1.43
  3. rustup install stable && rustup default stable fixed the issue

I have two extra things that might be of help:

  1. I do know that had a nightly version of rust running, to help check #4460 locally.
  2. I went back to nightly with rustup install stable && rustup default stable, but now IntelliJ shows version 1.45 correctly.

Seems to me like an environment configuration problem.

Just because it worked for you does not mean it is the solution to the problem… That’s actually not related to the actual problem, the final results are the same though. The real problem regarded in this issue is that somehow the plugin is not handling the environment variabless CARGO_HOME and RUSTUP_HOME correctly. The only way to get the IDE to recognize them is by launching it via a shell where those vars are set to the custom values, this is cumbersome and not up to the standards of JetBrains tooling in my opinion

This is still an issue! It’s certainly related to the custom install directories using environment variables…

@ortem Can you or any of the maintainers take a look?

Thanks

Again the same solution, rustup install stable & rustup default stable environment: Win: 11 Clion: 2022.1 rustc 1.60.0 cargo 1.60.0 rustup 1.24.3

For Toolchain location I have to change it to D:\rust\.rust\toolchains\stable-x86_64-pc-windows-msvc\bin to make it work. Toolchain version shows 1.49.0

  1. Are both IDEA and CLion installed and running under the same Windows user? Is it Administrator?
  2. Is Rust toolchain installed for the same user too?
  3. Could you please try $ rustup install stable && rustup default stable?

For everyone that have installed rust via home-brew and were ‘mislead’ by jetbrains tutorial: Try standard brew path: /opt/homebrew/bin

image

@ortem Is there any progress on this? Can I help you with trying out something?

I just found out, while exploring a different error, that it works out fine if I run the IDE from my bash session…

That said, I solved it by editing my ~/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/212.5284.44/bin/pycharm.sh file:

  • change shebang to #!/usr/bin/env bash (needed for source to work)
  • add source /opt/rust/env.sh before final run command

Where this is the content of /opt/rust/env.sh:

export CARGO_HOME="/opt/rust/cargo"
export RUSTUP_HOME="/opt/rust/rustup"
export PATH="$CARGO_HOME/bin:$PATH"
source "/opt/rust/cargo/env"

This is not a permanent solution though obviously since IDE update will break it…

Similar issue with recognising Rust toolchain : https://youtrack.jetbrains.com/issue/CPP-21793

OS: OS X Rust installed with brew

Hi @himhaidar ! Thanks for bringing our attention to this issue. It’s possible that in one of the future updates, we’ll add such functionality. In that case, we’ll reply with information to this ticket. Please stay subscribed to be informed.