crate_universe silently bootstraps cargo-bazel with hardcoded DEFAULT_RUST_VERSION when no toolchain is registered, producing confusing downstream errors
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- rust
- 領域
- build-system, tooling
調査の方向性
rust/private/common.bzl を読み、crate.from_specs/crate.spec のエントリポイントから cargo_bootstrap_repository を追跡します。rust.toolchain(...) を省略した MODULE.bazel で再現します。フォールバックが DEFAULT_RUST_VERSION を示し、明示的なツールチェーンを登録する方法を説明する警告を出力すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
When a Bazel module has no rust.toolchain(...) registered via
register_toolchains, crate_universe's pip.parse-equivalent
(crate.from_specs / crate.spec extension) silently falls back to
cargo_bootstrap_repository, which builds cargo-bazel from source using a
hardcoded DEFAULT_RUST_VERSION (currently "1.86.0" in rust/private/common.bzl).
If any of cargo-bazel's own pinned transitive dependencies require a newer
Rust language feature than that hardcoded version supports, the build fails
with a confusing compiler error inside a third-party crate deep in the
dependency tree (e.g. time-macros using a syntax feature stabilized after
1.86.0), with no indication that the real issue is "no toolchain was
registered, so we're bootstrapping cargo-bazel with an old pinned version."
Reproduction
- Create a Bazel module using bzlmod that depends on rules_rust's
crate_universe extension (e.g.crate.from_specs(...)), but does NOT call
rust.toolchain(...)/register_toolchains(...)anywhere in the module
or its transitive deps. - Run
bazel build //.... - Observe that cargo-bazel is built from source via
cargo_bootstrap_repository, using DEFAULT_RUST_VERSION, and that this is
not surfaced anywhere in the build output. - If cargo-bazel's own Cargo.lock pulls in a crate requiring a newer
language feature, the build fails with an opaque error[E0658] deep in a
[for tool] compilation, with no mention of the toolchain fallback.
Suggested improvement
Emit a print()/warning when cargo_bootstrap_repository is used because no
explicit toolchain was registered, e.g.:
"No rust.toolchain() registered for this module; bootstrapping cargo-bazel
from source using DEFAULT_RUST_VERSION (X.Y.Z). If the build fails with
confusing compiler errors in a [for tool] target, register an explicit
toolchain version via rust.toolchain(versions=[...])."
This would have saved significant debugging time in our case, where the fix
was simply adding an explicit rust.toolchain(edition="2021",
versions=["1.90.0"]) to MODULE.bazel.
Environment
- rules_rust 0.68.2-score (eclipse-score fork, unmodified in this code path)
- Bazel 8.6.0
- 主要言語
- Starlark
- スター
- 857
- フォーク
- 701
- 平均マージ
- 4日 7時間
- マージ済み PR(30日)
- 46
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bazelbuild/rules_rust のほかの issue
-
`rust_test(crate = ...)` does not stage the crate's transitive dynamic libraries into runfiles対応中かも @Wito-1 が 65 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
bazelbuild/rules_rust#4309 ·
メンテナーはふだん 3 日以内に返信
-
Windows (no-symlink path): drain_runfiles_dir_windows deletes retained runfiles — inverted filename_suffixes_to_retain condition対応中かも @Mattbusel が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
bazelbuild/rules_rust#4266 ·
メンテナーはふだん 3 日以内に返信
-
rust.toolchain(strip_level = ...) is silently ignored対応中かも @Mattbusel が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
bazelbuild/rules_rust#4223 ·
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 90/100
bazelbuild/rules_rust#4152 · リアクション 1 件 ·
メンテナーはふだん 3 日以内に返信
-
awaiting-response
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
bazelbuild/rules_rust#3599 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
bazelbuild/rules_rust の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
bazelbuild/apple_support#707 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
out-of-date
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
CachyOS/CachyOS-PKGBUILDS#2232 ·
メンテナーはふだん 1 日以内に返信
-
blast/large refactor risk/low spend-dem
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
chriskelly/MusicWall#87 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
neilotoole/sq#1503 ·
メンテナーはふだん 1 日以内に返信