In D49466, sys::path::replace_path_prefix was used instead startswith.
However those were reverted later (commit rG3bb24bf25767ef5bbcef958b484e7a06d8689204) due to broken Windows tests.
This patch is to restore those replace_path_prefix calls. The objective, in a follow-up patch, is to allow the prefix matching to be case-insensitive under Windows.
This patch reverts commit rG3bb24bf25767ef5bbcef958b484e7a06d8689204 except for the test fix it contains.
Does this need to be swapped?