diff --git a/oak_file_utils/src/lib.rs b/oak_file_utils/src/lib.rs index 5100afef61..127dc5ce9e 100644 --- a/oak_file_utils/src/lib.rs +++ b/oak_file_utils/src/lib.rs @@ -50,12 +50,13 @@ impl CompatRlocation for Option { #[cfg(feature = "bazel")] pub fn data_path(path: impl AsRef) -> PathBuf { const DATA_PATH_PREFIX: &str = "oak"; + let mut pb: PathBuf = DATA_PATH_PREFIX.into(); + pb.push(path); + let r = runfiles::Runfiles::create().expect("Couldn't initialize runfiles"); - let p = runfiles::rlocation!(r, format!("{DATA_PATH_PREFIX}/{}", path.as_ref().display())) - .compat_wrap() - .expect("Couldn't get runfile path"); + let p = runfiles::rlocation!(r, &pb).compat_wrap().expect("Couldn't get runfile path"); if !p.exists() { - panic!("Data dependency not found: {}", path.as_ref().display()); + panic!("Data dependency not found: {}", pb.display()); } p }