Skip to content

Stdlib .rmeta files not included in sysroot glob, causing "only metadata stub found" errors with recent Rust nightlies #3859

@redsun82

Description

@redsun82

Starting around nightly 2026-01-22 (rustc 1.95.0-nightly), the Rust distribution ships stdlib .rlib files as ~440-byte metadata stubs, with full metadata in separate .rmeta files alongside them. Previously, .rlib files contained the full metadata (~47MB each) and no .rmeta files existed.

The _build_file_for_stdlib_template glob only includes *.rlib and not *.rmeta, so the metadata files are excluded from the sysroot, causing:

error[E0786]: found invalid metadata files for crate `core`
  = note: only metadata stub found for rlib dependency `core`

Cargo builds with the same nightly work fine, confirming the issue is specific to how rules_rust assembles the sysroot.

Fix

Add *.rmeta to the glob:

     srcs = glob(
         [
             "lib/rustlib/{target_triple}/lib/*.rlib",
+            "lib/rustlib/{target_triple}/lib/*.rmeta",
             "lib/rustlib/{target_triple}/lib/*{dylib_ext}*",

_symlink_sysroot_tree symlinks all files from the stdlib target, so the new files will be picked up transitively. _rust_stdlib_filegroup_impl iterates over .rlib files specifically for ordering, but that should still work since .rlib files are still present.

Versions

  • rules_rust: 0.68.1
  • Rust: nightly-2026-01-22 (rustc 1.95.0-nightly)
  • Bazel: 8.x
  • Platforms confirmed: macOS aarch64, macOS x86_64 (cross-compile)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions