Repository navigation
Description
In a non-UTF-8 POSIX locale, seeded bin/pip launchers fail when the environment path contains a non-ASCII character. The launcher encodes its interpreter path as UTF-8, while the directory uses filesystem-encoded bytes. Running the environment's Python with -m pip still works.
Affected code
PipInstall._create_console_entry_point passes the interpreter path to distlib. ScriptMakerCustom._build_shebang and shell_shebang are also affected. The same paths remain at ebe06113.
Mechanism
distlib's ScriptMaker encodes the interpreter path as UTF-8 for the launcher. Python's os.fsencode uses the filesystem encoding for the actual path. Under ISO-8859-1, café on disk ends in caf\xe9; the launcher names caf\xc3\xa9. The kernel cannot find that interpreter. A long path or a path containing spaces takes shell_shebang, which also encodes the interpreter path as UTF-8.
#3412 checks this byte mismatch for shell activators. Its check does not cover seeded launchers; --activators= creates the environment and leaves bin/pip unusable.
Reproduction
Run this from the repository root with an installed ISO-8859-1 locale and the tox dev environment (tox r -e dev). It creates and removes a temporary environment and makes no network request.
env LC_ALL=en_US.iso88591 PYTHONUTF8=0 .tox/dev/bin/python - <<'PY'
import os
import subprocess
import sys
import tempfile
from pathlib import Path
from virtualenv import cli_run
with tempfile.TemporaryDirectory(prefix="virtualenv-locale-") as root:
dest = Path(root) / "caf\u00e9"
cli_run(["--no-periodic-update", "--activators=", str(dest)])
pip = dest / "bin" / "pip"
print(f"filesystem codec: {sys.getfilesystemencoding()}")
print(f"destination bytes: {os.fsencode(dest)!r}")
print(f"pip shebang: {pip.open('rb').readline()!r}")
try:
subprocess.run([pip, "--version"], check=True, capture_output=True)
except FileNotFoundError as error:
print(f"pip launch: {error.__class__.__name__}")
result = subprocess.run([dest / "bin" / "python", "-m", "pip", "--version"], check=True, capture_output=True)
print(f"python -m pip: {result.stdout.split()[0].decode('ascii')}")
PYObserved at ebe06113 with Python 3.15:
filesystem codec: iso8859-1
destination bytes: b'/tmp/virtualenv-locale-.../caf\xe9'
pip shebang: b'#!/tmp/virtualenv-locale-.../caf\xc3\xa9/bin/python\n'
pip launch: FileNotFoundError
python -m pip: pip
The launcher should start the interpreter in the environment. The same encoding path is present at the reported commit 8e09166d.
Impact
Reproducibility: moderate; this needs a non-UTF-8 POSIX locale, Python UTF-8 mode disabled, and a non-ASCII destination path. Exposure: unlikely; most current locales use UTF-8. For affected users, bin/pip cannot start. A different interpreter can run only if a sibling path with the UTF-8 spelling already exists; placing one requires control of the destination's trusted parent directory.
Credits
Reported by oss-scanner: ANT-2026-NU6BEMWZ (previously ANT-2026-DO7W8DK8).
Activity
🐛 fix(seed): launch pip in legacy locales
🐛 fix(seed): launch pip in legacy locales
🐛 fix(seed): launch pip in legacy locales
🐛 fix(seed): launch pip in legacy locales