Skip to content

Conversation

magurotuna
Copy link
Member

This fixes an issue where canonicalize_path_maybe_not_exists with RealSys failed to handle relative paths when traversing ancestors.

Fixes #19

Changes

  • When a relative path reaches an empty parent during ancestor traversal, now correctly defaults to current directory (.)
  • Removed unnecessary normalize_path preprocessing step
  • Added tests for both in-memory and real filesystem scenarios

Testing

  • Added test_canonicalize_path_maybe_not_exists_in_memory with various relative path cases
  • Added test_canonicalize_path_maybe_not_exists_real using temporary directories and symlinks
  • All tests verify correct path resolution for relative paths not prefixed with ., like d, c/d/e, etc.

@magurotuna magurotuna requested a review from dsherret October 9, 2025 07:15
path: &Path,
mut path: &Path,
) -> std::io::Result<PathBuf> {
let path = normalize_path(Cow::Borrowed(path));
Copy link
Member

@dsherret dsherret Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not normalizing the path anymore going to cause issues? Maybe it should still be normalized when not starting with a .?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think path normalization is done by fs_canonicalize anyway, so doing it would just be a duplicate work. Also as you can see we have tests confirming that paths not starting with . are handled expectedly.
I might be overlooking something though

@magurotuna magurotuna requested a review from dsherret October 11, 2025 06:06
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.

canonicalize_path_maybe_not_exists returns NotFound when relative path is given

2 participants