rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.25k stars 1.61k forks source link

Project causes multiple "Failed to run build scripts" #13400

Open augustocdias opened 2 years ago

augustocdias commented 2 years ago

rust-analyzer version: rust-analyzer 0.3.1238-standalone (61504c8d9 2022-10-08)

rustc version: rustc 1.64.0 (a55dd71d5 2022-09-19)

Opening this project (https://github.com/wireapp/core-crypto) I'm running into the following errors:

[ERROR project_model::workspace] cyclic deps: mls_crypto_provider(CrateId(223)) -> core_crypto_keystore(CrateId(98)), alternative path: core_crypto_keystore(CrateId(98)) -> mls_crypto_provider(CrateId(223))
[ERROR project_model::workspace] cyclic deps: mls_crypto_provider(CrateId(223)) -> mls_crypto_provider(CrateId(223)), alternative path: mls_crypto_provider(CrateId(223))
[ERROR flycheck] Flycheck failed to run the following command: "cargo" "clippy" "--workspace" "--message-format=json" "--manifest-path" "/Users/augusto/projects/core-crypto/Cargo.toml" "--all-targets" "--all-features"
[ERROR rust_analyzer::lsp_utils] cargo check failed

Cargo watcher failed, the command produced no valid metadata (exit code: ExitStatus(unix_wait_status(25856))):
error: -Zbuild-std requires --target

[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to run build scripts

error: -Zbuild-std requires --target

I could reproduce it in neovim and in vscode. The cyclic deps error are dev-dependencies and I think this is reported already.

Veykril commented 2 years ago

This comes from build-std being set https://github.com/wireapp/core-crypto/blob/36e34cacf1d143864795209f26b2579f01420408/.cargo/config.toml#L23, so when we compile build scripts the target flag is missing which becomes required with that setting I think. You can probably fix this by setting rust-analyzer.cargo.target to your host triple though that will cause analysis to consider the host triple only as well.

bjorn3 commented 2 years ago

That project depends on nightly rustc: https://github.com/wireapp/core-crypto/blob/36e34cacf1d143864795209f26b2579f01420408/.cargo/config.toml#L22 Try rustup override set nightly in the project directory and reopen vim.

augustocdias commented 2 years ago

This comes from build-std being set https://github.com/wireapp/core-crypto/blob/36e34cacf1d143864795209f26b2579f01420408/.cargo/config.toml#L23, so when we compile build scripts the target flag is missing which becomes required with that setting I think. You can probably fix this by setting rust-analyzer.cargo.target to your host triple though that will cause analysis to consider the host triple only as well.

This worked but not ideal :/

That project depends on nightly rustc: https://github.com/wireapp/core-crypto/blob/36e34cacf1d143864795209f26b2579f01420408/.cargo/config.toml#L22 Try rustup override set nightly in the project directory and reopen vim.

This had not effect at all.

augustocdias commented 2 years ago

Another issue I have in this specific project is that I get no diagnostics other than syntax errors. If I return the wrong type in a function it doesn't show anything.

ariel-miculas commented 1 year ago

I have a similar problem while working with autogenerated rust files, rust-analyzer cannot run the build script needed for generating the files (using capnp)