VSCode told me that racer crashed. When I restarted VSCode, it told me the rust-analyzer failed to load workspace and asked, "Is rust-src installed?" When I looked at the directory
I saw that it only has .DS_Store, Cargo.lock, and library. No src.
I tried rustup component add rust-src and rustup update stable, but both said I was up to date. I also tried rustup component remove rust-src followed by rustup component add rust-src, but no source.
How do I get my rust source back? Will I lose anything important if I uninstall rust and reinstall it?
Check if the env var RUST_SRC_PATH is set and unset it if so. If you update rust-analyzer to today's release it should tell you to do so if that variable is set.
RUST_SRC_PATH was set. (I think I may have set it in an attempt to fix the problem.) I unset it and restarted VSCode, but I got the same notification,
rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file /Users/alan/Documents/Eclipse/multicell/userspace/actix_server/Cargo.toml. Is rust-src installed?: could not find libcore in sysroot path `/Users/alan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src` (`RUST_SRC_PATH` might be incorrect, try unsetting it)
The VSCode terminal shows that RUST_SRC_PATH is not set. I tried uninstalling and reinstalling rust-analyzer in VSCode, but that didn't fix the problem. VSCode says I am using v0.2.344. Is that the latest?
The odd thing is that the VSCode editor seems to be working correctly. I get autocomplete and syntax errors are highlighted. The only anomalies are the notification and the status bar saying Racer: Crashed. The instructions for rust-analyzer say it may cause conflicts with the official Rust plugin, so I disabled it. I lose highlighting of syntax errors, and I still get the notification.
Good suggestions, @jyn514. How can I tell racer where to look? I tried changing rust.rustLangSrcPath in settings.json, and I get a slightly different notification.
rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file /Users/alan/Documents/Eclipse/multicell/userspace/actix_server/Cargo.toml. Is rust-src installed?: RUST_SRC_PATH must be absolute:
@jschievink: RUST_SRC_PATH does not show up when I echo $RUST_SRC_PATH or when I env | grep RUST in the VSCode terminal.
I then shut down VScode and restarted it. I verified that RUST_SRC_PATH is not set, but I still get
rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file /Users/alan/Documents/Eclipse/multicell/userspace/cellagent/Cargo.toml. Is rust-src installed?: RUST_SRC_PATH must be absolute:
and the status bar says Racer: Crashed.
I'm back where I started this thread, except no autocomplete doesn't show variables from my program. AAARRRGGGHHH!!!
Hi! The rust-analyzer extension does not use racer. Racer was the first attempt at providing autocomplete (correct me if I am wrong). Maybe you have two different rust ide support extensions installed?
racer is probably not updated anymore, because the official rls and rust-analyzer exist today.
In frustration, I took a (masked and socially distanced) walk. During my walk I remembered reading in the racer installation instructions that you could set RUST_SRC_PATH, but racer would find what it needed if you didn't. I realized that the environment variable wasn't set, but I had an entry for it in my settings.json. I removed that entry, restarted VSCode, and racer doesn't crash.
I was so proud of myself. Now @ruabmbua tells me that I don't need racer if I'm using rust-analyzer. I renamed racer in my .cargo/bin, restarted VSCode, and autocomplete works, verifying what he said. Of course, VSCode complains that a Rust tool is missing, but I can ignore that notification. Still, I might want to use racer with another editor, but I can't figure out how to tell VSCode not to even try to use it.
Oh, and by the way, I'm still getting
rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file /Users/alan/Documents/Eclipse/multicell/userspace/cellagent/Cargo.toml. Is rust-src installed?: RUST_SRC_PATH must be absolute:
every time I start VSCode, which is why I started this whole thread in the first place.
I can get my work done, but my Outline says No symbols found in 'foo.rs' and syntax errors don't show up as squiggly lines in the editor.
I had tried that before, but just to be sure I disabled the official Rust extension again and restarted VSCode. The VSCode status line tells me Racer: Not found and Rust Tools Missing. If I click on the latter I get a notification asking if I'd like to install racer. I still get the notification that rust-analyzer failed to load workspace.
Disabling didn't make a difference, but uninstalling did. VSCode no longer complains about racer. I still get the rust-analyzer failed to load workspace.
A bunch of stuff doesn't work in the editor. My OUTLINE is empty, no squiggly lines for syntax errors, and no type information shown when I hover. Those are all things that worked at one time or another. I can work without them, but they are nice to have.
It's fixed. I no longer get the rust-analyzer failed notification, and all editor features are working. The trick was disabling the Rust Extension Pack, which includes RLS. I did have to set rust.rustLangSrcPath in my settings.json. The only annoyance left is the VSCode status bar says Racer: Crashed.