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

Opening this crate in vscode on Linux leads to files being changed and an endless build loop #2777

Closed
RalfJung opened this issue Jan 6, 2024 · 5 comments · Fixed by #2778
Labels
enhancement New feature or request

Comments

@RalfJung
Copy link

RalfJung commented Jan 6, 2024

Summary

To reproduce, download this crate and open it in vscode on Linux with rust-analyzer installed. (I did that since I needed to grep for some things the crate does to research Windows-related issues in my code, and I don't have a Windows machine.) This leads to changes showing up in git diff, and rust-analyzer hangs in an endless build loop. I reported this with RA at rust-lang/rust-analyzer#16250 but they are saying there isn't much they can do; the reason is that this crate modifies its own source in a build script which causes a reload which causes a build which modifies the source again ad nauseam.

Crate manifest

No response

Crate code

No response

@RalfJung RalfJung added the bug Something isn't working label Jan 6, 2024
@kennykerr
Copy link
Collaborator

I don't use rust-analyzer because it makes VS Code unusable with the windows-rs repo. I don't really know what to do about that. It seems more of a rust-analyzer issue to me but perhaps I'm biased. The repo is just very very large and contains not only the windows and windows-sys crates in their entirety but also contains all of the code generation tooling, the windows-bindgen crate, that produces those crates. That tooling has very extensive testing included in the windows-rs repo that necessarily uses build scripts to generate a lot of code. While unusual, I don't see this as a bug.

Adding @ChrisDenton and @riverar perhaps they have more perspective.

@kennykerr kennykerr added question Further information is requested and removed bug Something isn't working labels Jan 6, 2024
@ChrisDenton
Copy link
Collaborator

ChrisDenton commented Jan 6, 2024

A workaround might be to exclude crates/tests/* from the workspace on your local copy, or maybe just exclude it from ra.

Maybe ra would be happier if we truncated files instead of removing and recreating?

@ChrisDenton
Copy link
Collaborator

Btw, I don't think doing codegen in build scripts is too bizarre. While it's rarer then other codegen methods (e.g. macros) it's not exactly unheard of.

@RalfJung
Copy link
Author

RalfJung commented Jan 6, 2024

Yeah codegen in build.rs is not uncommon and I think RA usually handles it fine. Not sure why it is causing a problem with this crate.

It does seem like build.rs is changing files in the src folder though, that is not common at all. Usually it puts its output into the OUT_DIR and then they get included into the regular build.

@kennykerr
Copy link
Collaborator

That's so I can use git diff during github builds to verify nothing has changed.

@kennykerr kennykerr added enhancement New feature or request and removed question Further information is requested labels Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants