rust-analyzer / rust-analyzer.github.io

https://rust-analyzer.github.io/
87 stars 51 forks source link

FetchBuildDataError in some default vscode installs #215

Open rfulwell opened 7 months ago

rfulwell commented 7 months ago

I did my best to faithfully follow defaults to install Rust and Rust Analyzer for WSL/Linux: https://www.rust-lang.org/learn/get-started https://code.visualstudio.com/docs/languages/rust

When launched on Debian 11 and Ubuntu 22.04 running in WSL2 I got the following error from the server:

[ERROR rust_analyzer::main_loop] FetchBuildDataError:
Failed to run build scripts for /workspaces/rust-analyzer-repro: No such file or directory (os error 2)

I prepared a dev container with a minimal set of files which reproduces the issue if you are set up to run remote containers: https://github.com/rfulwell/rust-analyzer-repro

Steps to reproduce:

  1. git pull https://github.com/rfulwell/rust-analyzer-repro
  2. cd rust-analyzer-repro; code .
  3. When prompted, reopen the project in a dev container
  4. Open the src/main.rs file and pause while the server processes the file
  5. Note the error as above and the status bar message with popup: image

The most simplified way I was able to find in order to work around the issue is to override three default settings. You can reproduce this by uncommenting the lines in the devcontainer.json file yourself or reverting the last commit in the repo.

So to reproduce the workaround, uncomment these lines and rebuild the dev container:

                // "rust-analyzer.cargo.buildScripts.enable": false,
                // "rust-analyzer.procMacro.attributes.enable": false,
                // "rust-analyzer.procMacro.enable": false

This does not seem to be a blocking issue for the extension but I don't like working with persistent errors in my environment so here we are. 😅