Skip to content

Commit 918fb43

Browse files
committed
Fix containment check by normalizing absolute cwd path
The containment check was failing when cwd was '.' because std::path::absolute converts it to '$PWD/.' without lexical normalization, while bundler_root is already normalized. This caused the starts_with check to fail incorrectly. The fix normalizes the absolute cwd path using normalize_lexically before comparison, ensuring both paths are in the same normalized form.
1 parent 2195f7d commit 918fb43

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎crates/socket-patch-core/src/crawlers/ruby_crawler.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,12 @@ impl RubyCrawler {
433433
// (`gemfiles/` recording `../vendor/bundle`). A root the user's
434434
// own environment moved outside the project bounds it instead.
435435
let containment = match &bundler_root {
436-
Some(root) if !std::path::absolute(cwd).is_ok_and(|p| root.starts_with(p)) => {
436+
Some(root)
437+
if !std::path::absolute(cwd)
438+
.ok()
439+
.and_then(|p| normalize_lexically(&p))
440+
.is_some_and(|p| root.starts_with(&p)) =>
441+
{
437442
root.clone()
438443
}
439444
_ => cwd.to_path_buf(),

0 commit comments

Comments
 (0)