Canonicalize relative path before looking up its parents

Several functions in cargo_toml need to look up workspace configuration. To do this, they attempt to look up parent directories of e.g. the specified Cargo.toml file by calling Path::parent().

Unfortunately, Path::parent() does not look up the true parent directory using filesystem operations, it only removes the last component from the path. Which means that it will return a weird result of Some("") if called with a file name like "Cargo.toml".

This will lead other parts of cargo_toml to fail down the line, as they make the invalid assumption that if path is a valid file path, then path.parent() is a valid directory path.

This MR proposes to fix the problem by canonicalizing relative paths before looking up their parent.

Edited by Hadrien G.

Merge request reports

Loading