Rust-analyzer failed to load workspace vscode - rust

I know that there are a lot of similar questions regarding rust-analyzer and I've checked them out but couldn't find the solution to my problem so I decided to ask a question myself. I've decided to start learning Rust and I'm having issues with rust-analyzer.
Here is my workspace structure:
I created a project using cargo and hoped that rust-analyzer will automatically register it but for some reason it fails.
I get this error message
> rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /home/remax/Storage/Projects/rust/rusttest/hello_cargo/Cargo.toml, cargo 1.61.0 (a028ae4 2022-04-29): Failed to run `"/home/remax/.cargo/bin/cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/remax/Storage/Projects/rust/rusttest/hello_cargo/Cargo.toml" "--filter-platform" "x86_64-unknown-linux-gnu"`: `cargo metadata` exited with an error: error: could not execute process `rustc -vV` (never executed)
Caused by:
No such file or directory (os error 2)
I honestly have no idea what to do.
My cargo version is 1.61.0
UPDATE: issue persists even with only rust project in workspace

You missed the rustup step. It is stated in the rust-analyzer extension that you need to install rustup first.
Quick start
install rustup
install the rust-analyzer extension.

rustup must be installed in the same system as Vscode. If you are using WLS Subsystem (like me), try installing rustup on Windows with the rustup-init.exe.
Run/Debug won't work (probably - I don't know why, but there's always cargo run) but you'll still get all the other features.

Related

failed to compile testmain package - compile, no such file

I'm new to Go programming and trying to set up the BDD framework Godog. I have extracted the Linux binary from the Github releases page and placed it on my $PATH. When I run it, I get the following error:
Error: failed to compile testmain package: fork/exec /opt/hostedtoolcache/go/1.17.7/x64/pkg/tool/linux_amd64/compile: no such file or directory - output:
For some reason godog version does not show an actual version, which leads me to believe it's not installed correctly.
❯ godog version
Show current version
Additional system information:
❯ go version
go version go1.18.3 linux/amd64
I don't know if this is relevant, but I'm using asdf to manage my local go installation.

Rust is not generating .profraw files for any project

I'm trying to follow this guide to be able to have source code coverage for a project in Rust.
I did the following:
Installed grcov
cargo install grcov
Added llvm-tools-preview
rustup component add llvm-tools-preview
Set my RUSTFLAGS variable to "-Zinstrument-coverage"
set RUSTFLAGS="-Zinstrument-coverage"
I build my project
cargo build
Set my LLVM_PROFILE_FILE variable to: "test-%p-%m.profraw"
set LLVM_PROFILE_FILE="test-%p-%m.profraw"
Run my tests with
cargo test
But no .profraw files appears, I only have the following:
Am I missing some extra configuration?
Here is my environment information:
cargo 1.57.0 (b2e52d7ca 2021-10-21)
release: 1.57.0
host: x86_64-pc-windows-msvc
os: Windows 10.0.18363 (Windows 10 Enterprise) [64-bit]
Thank you in advance for your help.
I was seeing similar behavior with rust 1.61 nightly on windows. I noticed warning messages stating ""test-%p-%m.profraw"" could not be written. In my case, the fix was to change how I set the LLVM_PROFILE_FILE environment variable. If I set it like:
set LLVM_PROFILE_FILE=test-%p-%m.profraw without the wrapping quotation marks and re-run my tests, the .profraw files are generated.
Your mileage may vary. I had the same issue with the RUSTFLAGS environment variable where I had to remove the quotes for it to even compile.
Another noteworthy thing I encountered with 1.61 is a warning that -Zinstrument-coverage is deprecated in favor of -Cinstrument-coverage.

React Native Awesome Project Build Fail

Been trying to run the start up AwesomeProject file in VS Code but every time I run npx react-native run-ios...the build fail below comes up. Have looked through the stacks, comments, and questions here but I cannot find anything that is applicable.
Tried to change my terminal and Xcode to load with Rosetta but I get an error there too...
softwareupdate --install-rosetta
Installing Rosetta 2 on this system is not supported.
Not sure where to go from here...
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/********/Library/Developer/Xcode/DerivedData/AwesomeProject-ekivgffrflagyugqmoefmykxoyqy/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-337605CB7CDF90939BEBF863ED22C375.sh (in target 'FBReactNativeSpec' from project 'Pods')
(1 failure)
info Run CLI with --verbose flag for more details.
I had this error too, i searched for hours...
What helped me was to downgrade version of react native to "react-native": "0.62.3" from 0.64
It also works with 0.63.
Others found this helpful: https://github.com/facebook/react-native/issues/32157

How do I debug `cargo build` hanging at "Updating crates.io index"?

My Rust project no longer builds after some conflicts between my RLS plugin and terminal build. I searched around the web and found suggestion of removing my ~/.cargo/registry/index/*, but after that I can't even build any project.
Now the build always stops at
Updating crates.io index
Passing in the --verbose option doesn't help so I don't even know whether it's dying. What should I do next? How to debug this issue?
Delete the ~/.cargo/.package-cache file.
Change cargo source in ~/.cargo/config. This works for me.
For example:
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

IntelliJ Haskell plugin: ghc-modi failed with error

I just installed IntelliJ idea and the official Haskell plugin.
IntelliJ couldn't find ghc-modi.exe, so I installed ghc-mod through cabal.
However, after importing my cabal project, I am still receiving the following error:
ghc-modi failed with error: NG BUG: GMECabalFlags (GMEString "extractField: failed extracting configFlags from input, input contained `configFlags'? False")
How can I solve or get more information on this error?
Thanks in advance.
This question has been answered by Atsky on GitHub:
This is internal problem of ghc-mod. It fails to read file dist/setup-config for some reason.
Try to remove dist folder from your project and then run cabal config.

Resources