Skip to content

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

@ArchangelX360

Description

@ArchangelX360

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 rust-lang/rust#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

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