rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

High number of dependencies could lead to `can't find crate` on Windows

Open ArchangelX360 opened this issue 2 months ago • 0 comments

rules_rust sets one -Ldependency statement per transitive dependency, leading to potentially a very long library search path.

The issue is, on Windows, in rustc the search paths get added to the PATH environment variable, but on Windows environment variables have a limit of 32,767 characters.

The probability of that bug happening in rules_rust is quite high. Could we try to workaround it until it is fixed at rustc's side?

See https://github.com/rust-lang/rust/issues/110889

Steps to reproduce

  1. Create a rust_library somecrate, it does not need to have sources
  2. Craete a rust_binary somebinary, with the following sources:
// main.rs
use somecrate::*;
pub fn main() {}
  1. Add somecrate to deps of somebinary, alongside many other (unused) dependencies
  2. Try to build somebinary

It should lead to:

error[E0463]: can't find crate for `somecrate`
 --> main.rs:1:5
  |
1 | use somecrate::*;
  |     ^^^^ can't find crate

ArchangelX360 avatar Dec 10 '25 20:12 ArchangelX360