How to debug the RA error like this one?

I am working on Frontier with the vscode. But RA always complains about the below errors. This question has troubled many people, there is another issue describing this, error on rust analyzer · Issue #709 · paritytech/frontier · GitHub. Any advice about this?

image

The RA server log:

[ERROR rust_analyzer::lsp_utils] failed to run build scripts

error: failed to run custom build command for `frontier-template-runtime v0.0.0 (/home/bear/working/darwinia/frontier/template/runtime)`

Caused by:
  process didn't exit successfully: `/home/bear/working/darwinia/frontier/target/debug/build/frontier-template-runtime-94adee7a60ecefe6/build-script-build` (exit status: 1)
  --- stdout
  e[1;33mInformation that should be included in a bug report.e[0m
  e[1;33mExecuting build command:e[0m "/home/bear/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/home/bear/working/darwinia/frontier/target/debug/wbuild/frontier-template-runtime/Cargo.toml" "--color=always" "--profile" "release"
  e[1;33mUsing rustc version:e[0m rustc 1.66.0-nightly (9c56d9d6f 2022-09-29)

How to reproduce

Make sure rustup target add wasm32-unknown-unknown --toolchain nightly the wasm target is installed before reproducing.

1. git clone https://github.com/paritytech/frontier.git
2. Add this repo to your Vscode editor, then, you can see the error after a while.

This is caused by the way parity works. Frontier has a build script invoking parity's wasm builder to build a wasm module. This means that every time you change the crate that will be compiled to wasm, the build script runs again. If there is a compilation failure, this will lead to the build script failing and rust analyzer helpfully reporting an error. It is not possible to report this error inline in the source code as the build script doesn't print the error messages in a format rust-analyzer understands.

Once it is stable if parity were to switch to artifact dependencies rather than a build script, this wouldn't be an issue anymore.

If there is a compilation failure, this will lead to the build script failing and rust analyzer helpfully reporting an error.

Thanks for your answer. I am still confused about this case. According to your analysis, if the compilation is OK, i.e. cargo check succeeds, this error message should not appear. However, it still appears. I have tested this based on the master branch.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.