From 3daf96e315d18e931df73ab58a7829ce115a100d Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Wed, 18 Sep 2024 09:10:01 -0700 Subject: [PATCH] Fix runfiles creation for directory based runfiles. (#2883) closes https://github.com/bazelbuild/rules_rust/issues/2868 --- tools/runfiles/runfiles.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/runfiles/runfiles.rs b/tools/runfiles/runfiles.rs index 94d8f2aa63..5c85762e8d 100644 --- a/tools/runfiles/runfiles.rs +++ b/tools/runfiles/runfiles.rs @@ -162,6 +162,10 @@ impl Runfiles { }; let repo_mapping = raw_rlocation(&mode, "_repo_mapping") + // This is the only place directory based runfiles might do file IO for a runfile. In the + // event that a `_repo_mapping` file does not exist, a default map should be created. Otherwise + // if the file is known to exist, parse it and raise errors for users should parsing fail. + .filter(|f| f.exists()) .map(parse_repo_mapping) .transpose()? .unwrap_or_default();