Skip to content

Windows executable detection tries to run 'python3.exe.__target__' etc #483

Description

@DuncanMackintosh

I only noticed this because our endpoint protection was blocking the execution and spamming me with popups about it, without that I suspect the impact is minimal but it's just wasting a bit of time.

The new Python Install Manager stores .exe.__target__ files in %LOCALAPPDATA%\python\bin, which is on %PATH% so gets searched - they're just text files containing the full path of a python executable.

pet picks them up and tries to run them, which naturally fails:

C:\Users\<user>\.vscode\extensions\ms-python.vscode-python-envs-1.36.0-win32-x64\python-env-tools\bin>pet.exe find
   0.385683000s ERROR pet_python_utils::env: Failed to spawn Python to resolve info "C:\\Users\\<user>\\AppData\\Local\\python\\bin\\python.exe.__target__": %1 is not a valid Win32 application. (os error 193)
   0.385896600s  WARN pet::find: Unknown Python Env "C:\\Users\\<user>\\AppData\\Local\\python\\bin\\python.exe.__target__"
   0.725347200s ERROR pet_python_utils::env: Failed to spawn Python to resolve info "C:\\Users\\<user>\\AppData\\Local\\python\\bin\\python3.12.exe.__target__": %1 is not a valid Win32 application. (os error 193)
   0.725571600s  WARN pet::find: Unknown Python Env "C:\\Users\\<user>\\AppData\\Local\\python\\bin\\python3.12.exe.__target__"
   1.071780100s ERROR pet_python_utils::env: Failed to spawn Python to resolve info "C:\\Users\\<user>\\AppData\\Local\\python\\bin\\python3.14.exe.__target__": %1 is not a valid Win32 application. (os error 193)
   1.071980800s  WARN pet::find: Unknown Python Env "C:\\Users\\<user>\\AppData\\Local\\python\\bin\\python3.14.exe.__target__"
   1.438984900s ERROR pet_python_utils::env: Failed to spawn Python to resolve info "C:\\Users\\<user>\\AppData\\Local\\python\\bin\\python3.exe.__target__": %1 is not a valid Win32 application. (os error 193)
   1.439173200s  WARN pet::find: Unknown Python Env "C:\\Users\\<user>\\AppData\\Local\\python\\bin\\python3.exe.__target__"

I'm guessing this is down to the lack of a trailing $ on the WINDOWS_EXE regex in crates/pet-python-utils/src/executable.rs but I don't know if that's intentional.

Presumably this will be more common as people migrate to the new Install Manager so probably worth excluding them from the search one way or another.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions