File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,21 @@ pub fn report_inaccuracies_identified_after_resolving(
3939 executable_not_in_symlinks = false ;
4040 }
4141
42- let mut invalid_prefix = env. prefix . clone ( ) . unwrap_or_default ( ) != resolved. prefix . clone ( ) ?;
43- if env. prefix . clone ( ) . is_none ( ) {
44- invalid_prefix = false ;
45- }
42+ let invalid_prefix = if let Some ( ref env_prefix) = env. prefix {
43+ let resolved_prefix = resolved. prefix . clone ( ) ?;
44+ // Canonicalize both paths to handle symlinks — a venv prefix like
45+ // /usr/local/venvs/myvenv may be a symlink to /usr/local/venvs/versioned/myvenv-1.0.51,
46+ // and sys.prefix returns the resolved target. Without this, the comparison
47+ // produces a false positive "Prefix is incorrect" warning. (See #358)
48+ // Wrap in norm_case to handle Windows UNC prefix (`\\?\`) from canonicalize.
49+ let env_canonical =
50+ norm_case ( std:: fs:: canonicalize ( env_prefix) . unwrap_or ( env_prefix. clone ( ) ) ) ;
51+ let resolved_canonical =
52+ norm_case ( std:: fs:: canonicalize ( & resolved_prefix) . unwrap_or ( resolved_prefix) ) ;
53+ env_canonical != resolved_canonical
54+ } else {
55+ false
56+ } ;
4657
4758 let mut invalid_arch = env. arch . clone ( ) != resolved. arch . clone ( ) ;
4859 if env. arch . clone ( ) . is_none ( ) {
You can’t perform that action at this time.
0 commit comments