intellij-rust / intellij-rust

Rust plugin for the IntelliJ Platform
https://intellij-rust.github.io
MIT License
4.53k stars 380 forks source link

Cargo project update failed: no explicit stdlib or rustup found #2267

Open devurandom opened 6 years ago

devurandom commented 6 years ago

When working on the Rust source code itself, IntelliJ Rust complains "Cargo project update failed: no explicit stdlib or rustup found". I am not sure what this means, exactly.

Further, IntelliJ Rust says at the top of any file that it "Can not attach stdlib sources automatically without rustup", but when I try to "Attach manually", it tells me that "Invalid Rust standard library source path: <.../rust/src/libstd>", where rust/src/libstd is the path to the source code of libstd. What exactly is IntelliJ Rust search for, when it asks for the location of that library source code?

It appears that these error message could be enriched to make it easier for the user to solve the issue. I would be glad to contribute such a patch, but am unable to do so without additional help and information.

devurandom commented 6 years ago

Is it possible, that what IntelliJ Rust actually wants, is the path to the Rust source code containing a "libstd" directory?

In which case it might get a little bit more automatism by looking at src/Cargo.toml and seeing that this is a copy of the Rust source code, and ask me whether I want to use that one.

devurandom commented 6 years ago

I'd like to assign this to myself, if possible, and see whether I can come up with some wording that's more detailed and easier to understand.

devurandom commented 6 years ago

Please note that #2275 does NOT yet detect that the currently open project is a copy of the Rust source code and hence it does not yet offer the user to just use this source.

QasimK commented 6 years ago

I have also tried to solve this by providing the path "/usr/lib/rustlib/src/rust/src/libstd" but it is not being accepted :(

Edit: Go with /usr/lib/rustlib/src/rust/src.

dkandalov commented 6 years ago

The problem still exists in the latest IJ (Build #IU-182.3911.13), Rust plugin Version: 0.2.0.2101-182.

In my case the problem seemed to be with rust installed via brew. After brew uninstall rust I followed installation instructions here https://www.rust-lang.org/en-US/install.html, i.e. curl https://sh.rustup.rs -sSf | sh. I had to point IJ to ~/.cargo/bin/rustc in a UI dialog but the error message was gone.

TriplEight commented 6 years ago

Faced the same problem, that's because I was following setup instructions from TheBook.

To prove it won't work type $ which rustup and it won't answer.

So to avoid that in IDEA you should uninstall Rust first:

  1. run /usr/local/lib/rustlib/uninstall.sh as root to uninstall Rust

  2. follow installation instructions on https://www.rust-lang.org/en-US/install.html or just $ curl r/[https://sh.rustup.rs](https://sh.rustup.rs) \-sSf | sh

  3. now $ which rustup should work, copy that path to IDEA.

  4. now it will loose the toolchain, which is here: /home/username/.cargo/bin

  5. and the standard library, IDEA will tell it can download it

Now it works.

rkmax commented 5 years ago

I can confirm this issue, create a new project from Rust application binary template and receive no explicit stdlib or rustup, but in my case I've installed rust 1.32.0 from my package manager. adding the path /usr/lib/rustlib/src/rust/src when the proyect is being created or later on the project settings solves the issue

t0r0X commented 5 years ago

On macOS had the same issue, with both InelliJ and CLion, and like @dkandalov I had Rust initially installed with Homebrew. With CLion I was able to build (IntelliJ kept complaining about missing SDK), but the error message was annoying. It looks like Homebrew does not install the sources, if I understand the problem correctly.

To get rid of it, I first uninstalled Rust: brew uninstall rust, brew cleanup. Then I installed rustup-init, and then with it I installed rustup (yes, I could have installed rustup manually, but I try to use as much as possible Homebrew and Sdkman):

After that, in the welcome dialogue I've let CLion retrieve the standard library: Configure > Preferences > Languages & Frameworks > Rust > 'Download via rustup'

Screenshot 2019-03-31 15 02 28

The library is then in /Users/USERNAME/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src: Screenshot 2019-03-31 15 20 37

New projects then have the settings already. Screenshot 2019-03-31 15 32 57

omenos commented 4 years ago

I was in the process of filling out an addition to this thread as I thought I had this problem, but I found a related issue. I hadn't personally gone into the global settings or project settings and set the Rust toolchain preferences as they were being autofilled at project creation time. However, I was still getting the issue reported above. While in the project (and global) settings, if I navigated to the Rust settings, the settable fields would be empty then autofill with the Apply button ready to be pressed. Once doing so the plugin works fine. It seems the settings (though showing correctly initially) actually weren't being set in the background.

CLion: 2019.3.4 Rust: 0.2.116.2163-193

kxxu commented 4 years ago

rustup did not successfully install and configure the stable toolchain, you can do it manually(in $home/.cargo/bin): rustup install stable rustup default stable after that, restart idea

f35f0ef9d0e827dae86552d3899f78fc commented 4 years ago

rustup did not successfully install and configure the stable toolchain, you can do it manually(in $home/.cargo/bin): rustup install stable rustup default stable after that, restart idea

This helped me. As an Arch user, I ran these commands to essentially reinstall Rust the way PyCharm wanted me to (I guess?):

sudo pacman -S rustup When it asks to remove Rust since it's in conflict, answer Y. rustup toolchain install stable Restart the IDE

itsmeadi commented 3 years ago

on MacOS, adding the rust path in global PATH worked for me sudo echo $HOME/.cargo/bin>>/etc/paths

Leniorko commented 2 years ago

rustup did not successfully install and configure the stable toolchain, you can do it manually(in $home/.cargo/bin): rustup install stable rustup default stable after that, restart idea

This helped me. As an Arch user, I ran these commands to essentially reinstall Rust the way PyCharm wanted me to (I guess?):

sudo pacman -S rustup When it asks to remove Rust since it's in conflict, answer Y. rustup toolchain install stable Restart the IDE

Worked for me. Thanks!

Daxe9 commented 2 years ago

as a linux user, i solved this problem by uninstall rust and install rustup using

curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

and restarting the ide should finish the work

aduntong commented 1 year ago

I think I know how to fix this issue for Windows 10 +. The toolchain location and standard library location is different with in the documents. Just set paths like following: toolchain location: C:\Users[username].rustup\toolchains\stable-x86_64-pc-windows-msvc\bin standard library: C:\Users[username].rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib