rust-analyzer: Regression in v0.2.686: `OUT_DIR` not set, enable "run build scripts" to fix

Repro: https://github.com/shikhar/bazel-tonic/tree/4a27fbf7fe15a26804a3eb5eb3f7b62dafa9fba4

image

The error does not make sense because that setting defaults to true.

The error is gone after after rolling back to the last release v0.2.678.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 25 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Same as @asaaki & @trentbb: discovered this when using bindgen in a workspace member crate. Made a reproduction repo with a minimal bindgen rust-analyzer --version: rust-analyzer 516eb40ba 2021-09-13 stable OS: Arch Linux x86_64 (5.14.2) Editor: Neovim 0.5

I have seen this issue right now myself, currently running RA nightly / 0.3.708 (VSC 1.59.0, Win10). Have not a repro repo, but I have a suspicion: The error happens when I work in a VSCode workspace with multiple folders/projects, but it does not happen when I open the project individually.

From a freshly generated one using tonic. Interestingly, it works perfectly fine on windows, but not on ubuntu (over VsCode SSH)

The project is basically their hello-world example

Reopening as folks are running into it, although I am not currently experiencing this problem.

ED: also running into this!

had the same effect on single-project workspace after deleting and rewriting build.rs restarting vs code did solve.

Same as @asaaki I am seeing this error when I have my whole workspace open. Opening up the individual project fixes the issue.

I’m facing the same issue in neovim with rust-tools.nvim in default config.

UPDATE: I’m using one include!(concat!(env!("OUT_DIR"), "")) for tonic_build generated sources and another for sources generated from a custom binary.

rust-analyzer versions tested:

  • 492407249 2022-03-09 nightly (Error: OUT_DIR not set, enable "run build scripts" to fix)
  • 4e72700e3 2022-02-28 stable (Error: OUT_DIR not set, enable "run build scripts" to fix)
  • 28e32fe40 2021-05-31 stable (Error: proc macro server crashed)

Versions in use:

  • cargo 1.59.0 (49d8809dc 2022-02-10)
  • rustc 1.59.0 (9d1b2106e 2022-02-23)
  • NVIM v0.6.1
  • Fedora release 35 (Thirty Five)

You can follow the instructions here: https://github.com/rust-analyzer/rust-analyzer/tree/master/docs/dev#launching-rust-analyzer

Can you post the configuration picked up by the extension? It should be printed to the “Output” tab under “Rust Analyzer Client”.