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 — Fix Poetry venv selection ignoring envs.toml (#476, #526) by mikolalysenko · Pull Request #527 · SocketDev/socket-patch Conversation
|
| Issue | Regression test | main | this PR |
|---|---|---|---|
#526 activated env (3.12/3.9/3.11 among 3.9–3.12; 3.10 vs 3.9 lexicographic trap) |
crawlers::python_crawler::tests::poetry_envs_toml_activated_env_is_the_only_one_probed |
❌ all 4 envs returned | ✅ |
#526 envs.toml beats VIRTUAL_ENV; conda prefix / base |
crawlers::python_crawler::tests::poetry_envs_toml_entry_overrides_virtual_env |
❌ VIRTUAL_ENV returned |
✅ |
#476 in-project = true (poetry.toml and POETRY_VIRTUALENVS_IN_PROJECT) with no ./.venv |
crawlers::python_crawler::tests::poetry_in_project_true_without_dot_venv_keeps_the_out_of_tree_env |
❌ [] |
✅ |
Two existing assertions encoded the #476 behaviour (in-project = true ⇒ nothing probed, and a None virtualenvs root). They now assert Poetry's behaviour instead.
main's code: 3 failed (output above). With the fix: cargo test -p socket-patch-core --lib -- crawlers::python_crawler gives 57/57 passed.find_local_venv_site_packages):
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 #526 layout: poetry env use python3.11, install, then poetry env use python3.12, install. The probe returns only envmulti-…-py3.12, which is what poetry env info -p prints. It still returns that env with an unrelated VIRTUAL_ENV=/tmp/other, and so does Poetry.poetry config --local virtualenvs.in-project true and install again, leaving no ./.venv. The probe returns ipapp-…-py3.11, matching poetry env info -p.cargo clippy --workspace --all-features -- -D warnings: clean.cargo test --workspace --all-features --no-fail-fast: all pass except 12 permission-based write-failure tests. They fail only because this sandbox runs as uid 0 (root ignores read-only bits), they fail the same way on main, and all 12 pass when re-run as uid 65534.rustfmt --check on the changed file: clean. main isn't cargo fmt-clean workspace-wide, so unrelated reflows were left out.envs.toml entry, Poetry picks the env matching the interpreter it would use (python on PATH or its own, depending on virtualenvs.use-poetry-python). Resolving that would mean running an interpreter, so in that case every env is still returned, as before.vex collapsing to the first copy (collapse_to_first) is tracked for npm in 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 / Fix agent vex checking only one installed copy (#516) #517.🤖 Generated with Claude Code
https://claude.ai/code/session_01Rh6wkfBxavb2aj1JWKbSxM
Note
Medium Risk
Changes which site-packages paths agent mode patches—a wrong choice previously left the real Poetry env unpatched; the new logic is more complex but targets documented Poetry behavior with regression tests.
Overview
Agent-mode Python crawling now picks the same virtualenv Poetry uses, instead of approximating it.
envs.toml (#526): The crawler reads <virtualenvs.path>/envs.toml for the env poetry env use recorded and probes only that <name>-<hash>-py<minor> tree. When that entry exists, an unrelated VIRTUAL_ENV is ignored; otherwise VIRTUAL_ENV or a non-base CONDA_PREFIX can still win, matching Poetry’s EnvManager.get().
In-project setting (#476): virtualenvs.in-project = true no longer blocks out-of-tree discovery when ./.venv is missing—only an existing ./.venv (and not an explicit in-project = false) counts as the in-project env. virtualenvs.path / envs.toml resolution is unchanged by in-project.
load_poetry_project takes an injected env lookup for tests; regression tests and docs/testing/poetry-compatibility.md agent-mode notes are updated. Anything that already uses find_local_venv_site_packages (hosted stale-install checks, VEX, etc.) inherits the fix.
Reviewed by Cursor Bugbot for commit 0b4a2df. Configure here.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Assisted-by: Claude Code:claude-opus-5-5
Agent mode, hosted mode's stale-install check and VEX picked the wrong Poetry virtualenv in two common setups, so the env `poetry run` uses stayed unpatched while the run reported success and VEX attested not_affected: - After `poetry env use 3.12` on a project that also has a 3.11 env, the alphabetically first env was patched. An unrelated activated VIRTUAL_ENV also won, although Poetry ignores it once envs.toml names the project (#526). - With `virtualenvs.in-project = true` but no ./.venv, the existing out-of-tree env Poetry keeps using was never probed (#476). Venv discovery now follows Poetry's EnvManager.get(): it reads envs.toml under virtualenvs.path, takes ./.venv only when it exists and in-project isn't false, and gates VIRTUAL_ENV / CONDA_PREFIX the way Poetry does. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0b4a2df. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
[agent] Ready for review at
Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
[burn-down agent] Labeled Ready for review at
Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Reviewed No actionable correctness/security regressions found. Checked Validation: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Resolve the python_crawler.rs conflict with the Poetry env selection fix (#527): keep main's poetry_active_prefix for VIRTUAL_ENV and add the PDM_IGNORE_ACTIVE_VENV gate on top. Assisted-by: Claude Code:claude-opus-5-5
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
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
Poetry with virtualenvs.in-project = true but no ./.venv keeps using its out-of-tree env, which socket-patch never probes: agent patches the global interpreter and hosted VEX falsely attests
There was an error while loading. Please reload this page.