From db7da314e7f0705c2f0e18b8d42d85e09ea04261 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 17 Jan 2025 21:18:12 -0800 Subject: [PATCH] Work around `cargo vendor` losing syntax_mapping builtins directory --- CHANGELOG.md | 2 ++ build/syntax_mapping.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 941e4e3c..7e30fbf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ## Other +- Work around build failures when building `bat` from vendored sources #3179 (@dtolnay) + ## Syntaxes ## Themes diff --git a/build/syntax_mapping.rs b/build/syntax_mapping.rs index 91a448f6..48468b9a 100644 --- a/build/syntax_mapping.rs +++ b/build/syntax_mapping.rs @@ -236,8 +236,14 @@ fn get_def_paths() -> anyhow::Result> { ]; let mut toml_paths = vec![]; - for subdir in source_subdirs { - let wd = WalkDir::new(Path::new("src/syntax_mapping/builtins").join(subdir)); + for subdir_name in source_subdirs { + let subdir = Path::new("src/syntax_mapping/builtins").join(subdir_name); + if !subdir.try_exists()? { + // Directory might not exist due to this `cargo vendor` bug: + // https://github.com/rust-lang/cargo/issues/15080 + continue; + } + let wd = WalkDir::new(subdir); let paths = wd .into_iter() .filter_map_ok(|entry| {