Skip to content

False positive "Prefix is incorrect" telemetry warning for symlinked venvs #358

@karthiknadig

Description

@karthiknadig

Problem

When a venv's prefix path is a symlink, the telemetry prefix comparison in report_inaccuracies_identified_after_resolving produces a false positive "Prefix is incorrect" warning.

Example: A venv at /usr/local/venvs/myvenv is a symlink to /usr/local/venvs/versioned/myvenv-1.0.51. During discovery, PET sets the prefix from the filesystem path (/usr/local/venvs/myvenv), but when resolving by spawning Python, sys.prefix returns the canonical path (/usr/local/venvs/versioned/myvenv-1.0.51). The direct path equality check flags this as an inaccuracy even though both paths refer to the same directory.

Root Cause

In crates/pet-telemetry/src/lib.rs, the prefix comparison does a direct != check:

let mut invalid_prefix = env.prefix.clone().unwrap_or_default() != resolved.prefix.clone()?;

On Unix, norm_case is a no-op, so symlinks are never resolved before comparison.

Fix

Canonicalize both prefix paths before comparing so that symlinked venvs are correctly identified as the same location.

Related: #357

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions