Skip to content

Commit 8de8f2b

Browse files
authored
Update runfiles to work with directory embedded manifests (#3399)
This fixes the ability to use runfiles in scenarios where a runfiles directory is created but all it contains is a `MANIFEST` file. This matches the behavior of: - rules_cc: https://github.com/bazelbuild/bazel/blob/c8217fdd2f20e4a061122c0af0417380d09e9480/tools/cpp/runfiles/runfiles_test.cc#L180-L196 - rules_shell: https://github.com/bazelbuild/bazel/blob/c8217fdd2f20e4a061122c0af0417380d09e9480/tools/bash/runfiles/runfiles.bash#L88-L96
1 parent a373426 commit 8de8f2b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rust/runfiles/runfiles.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,12 @@ impl Runfiles {
158158
let mode = if let Some(manifest_file) = std::env::var_os(MANIFEST_FILE_ENV_VAR) {
159159
Self::create_manifest_based(Path::new(&manifest_file))?
160160
} else {
161-
Mode::DirectoryBased(find_runfiles_dir()?)
161+
let dir = find_runfiles_dir()?;
162+
let manifest_path = dir.join("MANIFEST");
163+
match manifest_path.exists() {
164+
true => Self::create_manifest_based(&manifest_path)?,
165+
false => Mode::DirectoryBased(dir),
166+
}
162167
};
163168

164169
let repo_mapping = raw_rlocation(&mode, "_repo_mapping")

0 commit comments

Comments
 (0)