GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — With several Poetry envs for one project (`poetry env use` on two Python minors), agent mode patches the alphabetically first env instead of the one Poetry activated, and VEX attests not_affected · Issue #526 · SocketDev/socket-patch Closed Labels agent:triagedbugSomething isn't workingSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agentpm:poetryPoetryPoetrypriority:p1 Description[agent] Found by the scheduled Poetry bug-hunt routine (ledger #311). SummaryPoetry keeps one out-of-tree virtualenv per Python minor you've used with a project ( Since #330 (
Because the sort is lexicographic, the pick isn't even "lowest version": ImpactThis is a common setup: anyone who has moved a project to a newer Python with Repro (real Poetry, Linux, main
|
| Poetry | envs (first created → activated) | virtualenvs.path |
Patched env | Activated env patched? | VEX |
|---|---|---|---|---|---|
| 2.5.1 | 3.11 → 3.12 | custom (POETRY_VIRTUALENVS_PATH) |
py3.11 | no | not_affected ✗ |
| 2.5.1 | 3.11 → 3.12 | default cache dir, package-mode = false |
py3.11 | no | not_affected ✗ |
| 2.5.1 | 3.11 → 3.12 | default cache dir, package mode | py3.11 | no | not_affected ✗ |
| 2.5.1 | 3.10 → 3.13 | custom | py3.10 | no | not_affected ✗ |
| 1.8.5 | 3.11 → 3.12 | custom | py3.11 | no | not_affected ✗ |
| 2.5.1 | 3.12 → 3.11 | custom | py3.11 | yes (by luck) | ok |
| 2.5.1 | 3.13 → 3.10 | custom | py3.10 | yes (by luck) | ok |
| 1.8.5 | 3.12 → 3.11 | custom | py3.11 | yes (by luck) | ok |
macOS and Windows aren't tested (this routine's probe branches are blocked), but the selection logic is platform-independent.
This isn't a regression in a release. v4.0.0 and v3.3.0 don't discover these out-of-tree envs at all in this layout: package_not_installed, exit 0 (the #327 family). The wrong-env pick arrived with #330 (5678b76), which is unreleased.
crates/socket-patch-core/src/crawlers/python_crawler.rs:881: venvs.sort() orders the per-minor envs by name. Poetry's EnvManager.get() reads envs.toml (minor) for the active env, and falls back to the current interpreter's minor.crates/socket-patch-cli/src/commands/vex.rs:556: collapse_to_first. Agent-mode npm vex hashes only the first installed copy of a package, so it attests not_affected while another nested copy of the same name@version is unpatched #516 / PR Fix agent vex checking only one installed copy (#516) #517 cover the "VEX checks only the first copy" half for npm. That alone wouldn't fix this, because apply here also leaves the activated copy alone and reports already_patched.[agent] There's a second trigger with the same root cause (socket-patch doesn't read envs.toml). Reproduced 2/2 on main 61cfb9b with Poetry 2.5.1.
Poetry's EnvManager.get() (2.5.1, poetry/utils/env/env_manager.py) runs if not in_venv or env is not None: and only falls through to VIRTUAL_ENV / CONDA_PREFIX when envs.toml has no entry for the project. So after poetry env use 3.12, an unrelated activated venv in the shell is ignored by Poetry. socket-patch's find_local_venv_site_packages_with step 1 (python_crawler.rs:348) returns VIRTUAL_ENV first, unconditionally, for a Poetry project:
# project from the repro above, envs.toml: minor = "3.12" python3 -m venv /tmp/other && /tmp/other/bin/pip install six==1.16.0 VIRTUAL_ENV=/tmp/other $SP scan --mode agent $A --ecosystems pypi --yes --json # action "added" grep -c SOCKET-PATCHED /tmp/other/lib/python3.11/site-packages/six.py # 1 grep -c SOCKET-PATCHED $VENVS/envmulti-*-py3.12/lib/python3.12/site-packages/six.py # 0 VIRTUAL_ENV=/tmp/other poetry env info -p # …/envmulti-fsZqpEvf-py3.12 VIRTUAL_ENV=/tmp/other poetry run python -c "import six; print(six.__file__)" # the py3.12 copy, unpatched
The fix for #526 (honour envs.toml's minor) should also gate the VIRTUAL_ENV shortcut for Poetry projects the way Poetry does, the same way it's already gated for Pipenv (pipenv_uses_virtual_env). That includes CONDA_PREFIX / CONDA_DEFAULT_ENV != "base", which socket-patch doesn't read at all. I haven't tested conda (it isn't available in the sandbox).
Generated by Claude Code
poetry: run 7 (#526 filed)
[agent] Shares root cause with #476: socket-patch's Poetry venv lookup doesn't follow Poetry's EnvManager.get(). It ignores envs.toml (the env picked by poetry env use, which also overrides VIRTUAL_ENV), and it treats in-project = true as "only ./.venv" even when ./.venv doesn't exist. Will be fixed together.
Generated by Claude Code
[agent] Claiming this issue (with #476; shared root cause: Poetry venv lookup doesn't follow Poetry's EnvManager.get() env selection). Branch: agent/fix-poetry-env-selection. Claim-ID: 2026-10-02T03:21:02Z-899515
Generated by Claude Code