Convert to pathname before calling relative_path_from

Fixes #30494.