-
Notifications
You must be signed in to change notification settings - Fork 3
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
Build fails under Windows locally: unresolved import winapi::shared::winerror
#92
Comments
I get a different error when building on windows on my local machine:
A git bisect shows that 16f99a9 is also the culprit, but presumably for a different reason of also updating protobuf. Looks like at least one other user has reported this: protocolbuffers/protobuf#19410 (comment) |
Does it go away if you execute "bazel clean" and retry? I think I have seen this issue at some point as well, but it maybe related to .d file being cached and not recreated b/c bazel thought it the action does not need to be rerun (e.g. because only something like --experimental_sibling_repository_layout flag changed). |
For the original issue, I think it maybe duplicate of bazelbuild/rules_rust#2946, the winapi is only runtime dependency in the graph. It through e.g. Not sure why it works on CI though yet, but reverting this line in the rules_rust helps locally as well (although it seems it's wrong thing to do): Unfortunately each build on Windows takes minutes. |
After a |
The cargo_tree_resolver discovers dependencies by executing `cargo tree` for different host and target triples. This procedure breaks when cargo successfully but incorrectly caches rustc info. Incorrect cache hit may happen because cache key does not take into account HOST_TRIPLE env variable used by `rules_rust` to force rustc to report it's built for different host. The caching may happen if one has target/ directory in repo, or it was created through running some commands outside of bazel. Details: After recent fixes to support properly bzlmod (bazelbuild#3034) noticed issues under windows when building bazel-lsp: cameron-martin/bazel-lsp#92 Cargo may cache rustc info in target/.rustc_info.json : https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L163 The rules_rust hacks rustc by setting HOST_TRIPLE: https://github.com/bazelbuild/rules_rust/blob/3aecdbedba0c001d0660ff631aeccb35d94ff3a7/crate_universe/src/metadata/cargo_tree_resolver.rs#L152 The HOST_TRIPLE env variable is not taken into account by cargo when checking whether cached rustc info is valid: https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L320
The cargo_tree_resolver discovers dependencies by executing `cargo tree` for different host and target triples. This procedure breaks when cargo successfully but incorrectly caches rustc info. Incorrect cache hit may happen because cache key does not take into account HOST_TRIPLE env variable used by `rules_rust` to force rustc to report it's built for different host. The caching may happen if one has target/ directory in repo, or it was created through running some commands outside of bazel. Details: After recent fixes to support properly bzlmod (bazelbuild#3034) noticed issues under windows when building bazel-lsp: cameron-martin/bazel-lsp#92 Cargo may cache rustc info in target/.rustc_info.json : https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L163 The rules_rust hacks rustc by setting HOST_TRIPLE: https://github.com/bazelbuild/rules_rust/blob/3aecdbedba0c001d0660ff631aeccb35d94ff3a7/crate_universe/src/metadata/cargo_tree_resolver.rs#L152 The HOST_TRIPLE env variable is not taken into account by cargo when checking whether cached rustc info is valid: https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L320
The cargo_tree_resolver discovers dependencies by executing `cargo tree` for different host and target triples. This procedure breaks when cargo successfully but incorrectly caches rustc info. Incorrect cache hit may happen because cache key does not take into account HOST_TRIPLE env variable used by `rules_rust` to force rustc to report it's built for different host. The caching may happen if one has target/ directory in repo, or it was created through running some commands outside of bazel. Details: After recent fixes to support properly bzlmod (bazelbuild#3034) noticed issues under windows when building bazel-lsp: cameron-martin/bazel-lsp#92 Cargo may cache rustc info in target/.rustc_info.json : https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L163 The rules_rust hacks rustc by setting HOST_TRIPLE: https://github.com/bazelbuild/rules_rust/blob/3aecdbedba0c001d0660ff631aeccb35d94ff3a7/crate_universe/src/metadata/cargo_tree_resolver.rs#L152 The HOST_TRIPLE env variable is not taken into account by cargo when checking whether cached rustc info is valid: https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L320
Closing it as it's enough to remove target/ directory locally if one created it. Created PR to rules_rust with permanent fix. |
The cargo_tree_resolver discovers dependencies by executing `cargo tree` for different host and target triples. This procedure breaks when cargo successfully but incorrectly caches rustc info. Incorrect cache hit may happen because cache key does not take into account HOST_TRIPLE env variable used by `rules_rust` to force rustc to report it's built for different host. The caching may happen if one has target/ directory in repo, or it was created through running some commands outside of bazel. # Details - After recent fixes to support properly bzlmod (#3034) noticed issues under windows when building bazel-lsp: cameron-martin/bazel-lsp#92 - Cargo may cache rustc info in target/.rustc_info.json : https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L163 - The rules_rust hacks rustc by setting HOST_TRIPLE: https://github.com/bazelbuild/rules_rust/blob/3aecdbedba0c001d0660ff631aeccb35d94ff3a7/crate_universe/src/metadata/cargo_tree_resolver.rs#L152 - The HOST_TRIPLE env variable is not taken into account by cargo when checking whether cached rustc info is valid: https://github.com/rust-lang/cargo/blob/769f622e12db0001431d8ae36d1093fb8727c5d9/src/cargo/util/rustc.rs#L320
Extracted from #62
For some reason was not able to build bazel-lsp on current HEAD though, running git-bisect shows this PR as culprit: #69
I am getting an errors like:
It works on CI but fails on my machine, something seems wrong here.
Adding below lines to Cargo.toml helps in my case:
Bisect on rules_rust points to this PR as one that changed behavior here: bazelbuild/rules_rust#3034
The text was updated successfully, but these errors were encountered: