Skip to content

Replace path_abs dependency with std::path::absolute#3622

Open
Xavrir wants to merge 3 commits intosharkdp:masterfrom
Xavrir:replace-path-abs-with-std
Open

Replace path_abs dependency with std::path::absolute#3622
Xavrir wants to merge 3 commits intosharkdp:masterfrom
Xavrir:replace-path-abs-with-std

Conversation

@Xavrir
Copy link
Contributor

@Xavrir Xavrir commented Mar 8, 2026

Summary

Replaces the path_abs crate (and its transitive dependency std_prelude) with std::path::absolute(), which has been stable since Rust 1.79. Bat's MSRV is 1.88, so this is safe to use.

A lexical normalization step is applied after path::absolute() to match PathAbs::new() behavior of stripping . and resolving .. components, ensuring syntax mapping globs continue to match correctly.

Changes

  • src/assets.rs: Replace PathAbs::new(path) with absolute_normalized(path) using std::path::absolute() + component normalization
  • Cargo.toml: Remove path_abs dependency
  • Cargo.lock: Updated (removes path_abs and std_prelude)
  • CHANGELOG entry

Impact

  • Removes 2 crates from the dependency tree (path_abs, std_prelude)
  • Net -3 lines of code (21 added, 24 removed)
  • Behavior is identical: both make paths absolute without following symlinks, with ./.. normalization

Testing

  • 377 tests pass (cargo test)
  • Existing syntax_detection_for_symlinked_file test passes (verifies path absolutization still works correctly for syntax detection)

Xavrir added 3 commits March 8, 2026 12:15
std::path::absolute() has been stable since Rust 1.79 and bat's MSRV is
1.88. This replaces path_abs (and its transitive dep std_prelude) with
the standard library function, reducing the dependency count by 2.

A lexical normalization step is applied after making the path absolute
to match PathAbs::new() behavior of resolving . and .. components.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant