Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in v0.2.686: OUT_DIR not set, enable "run build scripts" to fix #9720

Closed
shikhar opened this issue Jul 29, 2021 · 28 comments
Closed
Labels
C-support Category: support questions S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@shikhar
Copy link

shikhar commented Jul 29, 2021

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.

@jonas-schievink
Copy link
Contributor

I cannot reproduce this on current master (8a6bac3) with Rust 1.53.0

@shikhar
Copy link
Author

shikhar commented Jul 29, 2021

How do I try master? I switched to the nightly channel and still see this.

@jonas-schievink
Copy link
Contributor

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".

@shikhar
Copy link
Author

shikhar commented Aug 2, 2021

Hmm, I can't reproduce this problem on another machine, so closing

@shikhar shikhar closed this as completed Aug 2, 2021
@asaaki
Copy link

asaaki commented Aug 15, 2021

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.

@trentbb
Copy link

trentbb commented Aug 27, 2021

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

@chris-ricketts
Copy link

chris-ricketts commented Sep 18, 2021

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

@declark1
Copy link

Also seeing this error when having my whole workspace open with multiple crates. Has anyone figured out a solution?

@shikhar
Copy link
Author

shikhar commented Oct 19, 2021

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

ED: also running into this!

@shikhar shikhar reopened this Oct 19, 2021
@Raz-Hemo
Copy link

Raz-Hemo commented Nov 4, 2021

Also running into this when opening a workspace with multiple crates on vscode remote ssh.

@h0ru5
Copy link

h0ru5 commented Nov 7, 2021

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

@Veykril Veykril added the S-unactionable Issue requires feedback, design decisions or is blocked on other work label Dec 14, 2021
@jkcoxson
Copy link

I am also running into this problem, with one folder open at a time and my whole workspace. Restarting VS Code has no effect.

@Veykril
Copy link
Member

Veykril commented Dec 21, 2021

Meant to look into this, tried out @chris-ricketts repro but it works fine for me.
image

So for those that still run into this we need a new reproduction it seems

@dxenonb
Copy link

dxenonb commented Dec 29, 2021

For what it's worth, this is what I am running into:

I have a workspace with my game project (rust_voxel) and a renderer crate in the workspace

  1. (user error:) My game project was failing with this error for some bindgen generated bindings (OUT_DIR not set)
  2. (possibly this issue:) Yesterday, with gl-generator, RA was reporting errors on use crate::gl::types::*; (gl is a module which contains the include)... Today that's not happening and everything looks fine (even before I fixed the issue above). The repro above still looks consistent with my setup but is not giving me the error today either

I'm running things a little out of date and will update later (since everything is working right now):

  • rustc 1.57.0 (f1edd0429 2021-11-29)
  • ra d9b2291 2021-11-29 stable
  • VSCode 1.60.1

What I was doing to cause the first error:

It turns out I had this in my build script:

  let date = Command::new("date")
          .arg("+%Y-%m-%d")
          .output()

The only indication I found that RA was struggling was in the VS Code terminal:

[ERROR rust_analyzer::reload] failed to switch build data: rust-analyzer failed to run build scripts:
error: failed to run custom build command for `rust_voxel v0.1.0 (E:\Code\gitlab\rust_voxel)`

Caused by:
  process didn't exit successfully: `e:\Code\gitlab\rust_voxel\target\debug\build\rust_voxel-f1dd21816edff2bf\build-script-build` (exit code: 101)

Handling the Result::Err in my build script (cannot find the date command), the OUT_DIR issue is gone.

Perhaps others here have panics in their build scripts?

Not sure if this is a new issue or not. (n.b. you have to reload RA to get the include! macro to appear as an error - it looks like generated files linger in the VFS based on the extension's output)

This is a repro for how build script panics act (uncomment the panic in the build script):

https://github.com/dxenonb/ra-build-script-panic

@35359595
Copy link

35359595 commented Dec 30, 2021

I have same issue with substrate wasm builder and wasm binary inclusion macro

versions:
rustc 1.57.0-nightly (5b210643e 2021-10-11)
cargo 1.57.0-nightly (d56b42c54 2021-09-27)
rust-analyzer 7d6fcbc 2021-12-07 dev
MacOS 12.1

Screen Shot 2021-12-30 at 12 29 57

@ahicks92
Copy link

Saw this spuriously, and now Rust-analyzer is stuck with (copying as JSON in case it's more useful):

[{
	"resource": "/c:/projects/in_progress/ammo/protos/src/lib.rs",
	"owner": "rustc",
	"code": {
		"value": "macro-error",
		"target": {
			"$mid": 1,
			"external": "https://rust-analyzer.github.io/manual.html#macro-error",
			"path": "/manual.html",
			"scheme": "https",
			"authority": "rust-analyzer.github.io",
			"fragment": "macro-error"
		}
	},
	"severity": 8,
	"message": "failed to load file `c:\\projects\\in_progress\\ammo\\target\\debug\\build\\ammo_protos-ffd2ea0eb1b32fb8\\out/frontend.rs`",
	"source": "rust-analyzer",
	"startLineNumber": 10,
	"startColumn": 5,
	"endLineNumber": 10,
	"endColumn": 56
}]

Rust-analyzer is 0.2.853.

And the known-bad commit that the above error is from is here: audio-mmo/monorepo@f227216

@Coronon
Copy link

Coronon commented Feb 2, 2022

Also facing this rn, is there any hotfix?

@bjorn3
Copy link
Member

bjorn3 commented Feb 2, 2022

You can use "rust-analyzer.diagnostics.disabled": ["macro-error"] to disable presentation of the error. Which project do you get this error on by the way?

@Coronon
Copy link

Coronon commented Feb 2, 2022

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

@SHiftLin
Copy link

The same problem occurs

@GLodi
Copy link

GLodi commented Feb 23, 2022

If anyone is using Emacs with lsp-mode, a simple M-x lsp-workspace-restart seemed to do the trick.

@g0hl1n
Copy link

g0hl1n commented Mar 8, 2022

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:

  • 4924072 2022-03-09 nightly (Error: OUT_DIR not set, enable "run build scripts" to fix)
  • 4e72700 2022-02-28 stable (Error: OUT_DIR not set, enable "run build scripts" to fix)
  • 28e32fe 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)

@bjorn3
Copy link
Member

bjorn3 commented Mar 9, 2022

Which project?

@flodiebold flodiebold added the C-support Category: support questions label Mar 11, 2022
@oldgalileo
Copy link

Using the MacPorts rust-analyzer (https://ports.macports.org/port/rust-analyzer/details/) and running into the same issue, with a similar setup to @g0hl1n but running:

  • cargo 1.56.0 (4ed5d137b 2021-10-04)
  • rustc 1.56.1 (59eed8a2a 2021-11-01)
  • NVIM v0.7.0-dev+1299-g773516365
  • macOS 12.0.1

bors added a commit that referenced this issue Apr 14, 2022
internal: Show more project building errors to the user

Should help out with #9720
Fixes #11223
@Veykril
Copy link
Member

Veykril commented Apr 16, 2022

#11960 added some better error reporting which should help with this. I am going to close this now as there is a ton of stale information in here. If you do run into this, please do open a new issue, with the Rust Analyzer Language Server log output and ideally a sample reproducer.

@Veykril Veykril closed this as completed Apr 16, 2022
@TulioMeran
Copy link

TulioMeran commented Jul 3, 2024

Hi,

in my case the solution was install protobuf in my local machine, I use Mac so I ran "brew install protobuf" after that I was complete the project and the error is done.

@jswhisperer
Copy link

tauri-apps/tauri#8442 solved closing vs-code and reopen also maybe

@ZeeshanAhmadKhalil
Copy link

Restarting the VS code fixed the issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-support Category: support questions S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests