bazelbuild / bazelbuild/rules_rust
error when building `utoipa-swagger-ui` with crate_universe
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
Here's a GitHub gist you can clone to repro the issue I'm seeing: https://gist.github.com/oconnor663/deaad1cacdcbf98e8e21f73b163827b5. The minimal `MODULE.bazel` file looks like this:
```
module(
name = "repro",
version = "0.1.0",
)
bazel_dep(name = "rules_rust", version = "0.55.6")
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
crate.spec(package = "utoipa-swagger-ui", version = "8.0.3")
crate.from_specs()
use_repo(crate, "crates")
```
The trivial `rust_binary` target that depends on that crate is:
```
package(default_visibility = ["//visibility:public"])
load("@rules_rust//rust:defs.bzl", "rust_binary")
rust_binary(
name = "bin",
srcs = ["repro.rs"],
deps = [
"@crates//:utoipa-swagger-ui",
],
)
```
If I build that, I get this error ("folder ... does not exist"):
```
$ git clone https://gist.github.com/deaad1cacdcbf98e8e21f73b163827b5.git repro
...
$ cd repro
$ bazel build :bin
INFO: Analyzed target //:bin (0 packages loaded, 0 targets configured).
ERROR: /private/var/tmp/_bazel_jacko/92410d0e3373f265902564b48493ac12/external/rules_rust~~crate~crates__utoipa-swagger-ui-8.0.3/BUILD.bazel:18
:13: Compiling Rust rlib utoipa_swagger_ui v8.0.3 (6 files) failed: (Exit 1): process_wrapper failed: error executing Rustc command (from targe
t @@rules_rust~~crate~crates__utoipa-swagger-ui-8.0.3//:utoipa_swagger_ui) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_r
ust~/util/process_wrapper/process_wrapper --env-file ... (remaining 79 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: #[derive(RustEmbed)] folder '/private/var/tmp/_bazel_jacko/92410d0e3373f265902564b48493ac12/sandbox/darwin-sandbox/127/execroot/_main/ba
zel-out/darwin_arm64-fastbuild/bin/external/rules_rust~~crate~crates__utoipa-swagger-ui-8.0.3/_bs.out_dir/swagger-ui-5.17.14/dist/' does not ex
ist. cwd: '/private/var/tmp/_bazel_jacko/92410d0e3373f265902564b48493ac12/sandbox/darwin-sandbox/130/execroot/_main'
```
(Another error follows that that's pretty clearly downstream of this file-does-not-exist problem.)
`utoipa-swagger-ui` isn't my crate, but I think the basic issue is that its `build.rs` is [generating some code that embeds a path into its `target/` dir](https://github.com/juhaku/utoipa/blob/e9eebd0d191a428203478f35be77ee2a6c1b0352/utoipa-swagger-ui/build.rs#L217). I'm guessing that plays poorly with the way Bazel/rules_rust/crate_universe compiles crates under different sandbox dirs, but I'm not really sure. Is there a way for me to specify this dependency that will build? Apologies if this isn't really a `rules_rust` issue.
Contributor guide
Assessment
This issue has not been assessed yet.