rust_doc_test: no way to set environment variables for the test runner (generated script does `exec env -`)
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- rust
- Área
- build-system
Línea de trabajo
Empieza por rust/private/rustdoc_test.bzl y la ruta de rustdoc_test_writer; después, sigue _construct_writer_arguments y el manejo existente de env en rust_test. Confirma cómo el script generado ensambla sus variables --action_env. Se considera terminado cuando rust_doc_test acepta los atributos de entorno solicitados, conserva las variables en el entorno de ejecución y admite el ejemplo de NIX_LD sin debilitar el borrado existente del entorno.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
rust_doc_test is the only test rule in rules_rust that execs a toolchain tool
(rustdoc) at test runtime rather than build time. The script generated by
rustdoc_test_writer begins with:
exec env - \
CARGO_CRATE_NAME='...' \
... \
'.../process_wrapper' ... '.../bin/rustdoc' ...
env - clears the entire environment and re-sets only the writer's explicit
list (CARGO_*, plus the hardcoded --action_env passthroughs: DEVELOPER_DIR,
PATHEXT, SDKROOT, SYSROOT). There is no user-facing way to add to that list:
rust_doc_testhas noenvattribute (checked on 0.70.0 and currentmain).- Bazel's
--test_envdoesn't help: the variables reach the test action, but
the generated script's ownenv -discards them before rustdoc runs.
Why this matters: remote execution on NixOS-style images
On RBE worker images where the prebuilt Rust toolchain runs through a loader
shim such as nix-ld (the FHS ELF
interpreter path is a shim that resolves the real dynamic loader via the
NIX_LD env var), every rustdoc invocation from the generated script dies
instantly:
[nix-ld] FATAL: panicked at src/main.rs:187:55:
called `Result::unwrap()` on an `Err` value: Posix(2)
Build-time rustc/rustdoc actions on the same workers are fine — build actions
can carry the needed variables via --action_env / the image environment. The
doc-test runner is the one place where the environment is force-cleared with
no escape hatch, so rust_doc_test targets pass locally and hard-fail on RBE.
Feature request
Support the conventional env (and ideally env_inherit) attributes on
rust_doc_test, merged into the variable list the test writer bakes into the
generated script (i.e. flowing into _construct_writer_arguments /
--action_env), with env subject to the usual location/make-variable
expansion like rust_test.env.
That would make this work:
rust_doc_test(
name = "mycrate_doc_test",
crate = ":mycrate",
env = {"NIX_LD": "/lib/my-real-ld.so"},
)
Workaround we settled on
Not really a workaround for doc tests in general: we removed the
rust_doc_test target and restated the invariant our compile_fail doctest
proved (a type must not implement Clone) as an in-crate impl-ambiguity
assertion, keeping the doctest as documentation only (run via
cargo test --doc outside Bazel). Crates that rely on doc tests for real
example coverage have no equivalent escape.
Versions
- rules_rust 0.70.0 (bzlmod), also inspected
rust/private/rustdoc_test.bzl
onmain— attrs are stillcrate,crate_features,deps,
proc_macro_deps,rustdoc_flags+ privates; noenv. - Bazel 8, remote execution via REAPI, Linux x86_64 workers on a
Nix-built container image using nix-ld for FHS binaries.
- Lenguaje dominante
- Starlark
- Estrellas
- 857
- Forks
- 701
- Merge medio
- 4 d 7 h
- PR fusionados (30 d)
- 46
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bazelbuild/rules_rust
-
`rust_test(crate = ...)` does not stage the crate's transitive dynamic libraries into runfilesPosiblemente ocupada @Wito-1 la tomó hace 65 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
bazelbuild/rules_rust#4309 ·
Los mantenedores suelen responder en 3 días
-
Windows (no-symlink path): drain_runfiles_dir_windows deletes retained runfiles — inverted filename_suffixes_to_retain conditionPosiblemente ocupada @Mattbusel la tomó hace 17 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
bazelbuild/rules_rust#4266 ·
Los mantenedores suelen responder en 3 días
-
rust.toolchain(strip_level = ...) is silently ignoredPosiblemente ocupada @Mattbusel la tomó hace 17 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
bazelbuild/rules_rust#4223 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 90/100
bazelbuild/rules_rust#4152 · 1 reacción ·
Los mantenedores suelen responder en 3 días
-
awaiting-response
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
bazelbuild/rules_rust#3599 · 1 comentario ·
Los mantenedores suelen responder en 3 días
Todos los issues de bazelbuild/rules_rust
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
bazelbuild/apple_support#707 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
-
blocky: new version 0.38.0Abiertoout-of-date
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
CachyOS/CachyOS-PKGBUILDS#2232 ·
Los mantenedores suelen responder en 1 día
-
blast/large refactor risk/low spend-dem
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
chriskelly/MusicWall#87 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
neilotoole/sq#1503 ·
Los mantenedores suelen responder en 1 día