Repository navigation
Fix Pipenv venv missed with Pipfile venv_in_project (#842) - #1729
Mikola Lysenko (mikolalysenko) merged 3 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
A Pipfile with `[pipenv] venv_in_project = true` and no ./.venv made discovery conclude that Pipenv had no venv yet. Only Pipenv 2026.2+ reads that key: 2018.11 through 2026.1 keep the venv in WORKON_HOME. On those versions agent scan skipped an installed package as "not installed", leaving the venv unpatched with exit 0, and hosted scan lost its stale-install warning. The "no venv yet" answer now comes only from PIPENV_VENV_IN_PROJECT, which every Pipenv reads. With the Pipfile key alone, the WORKON_HOME venv is still found. Fixes #842 Assisted-by: Claude Code:claude-opus-5-5
Review follow-up. Only a truthy PIPENV_VENV_IN_PROJECT means every Pipenv uses ./.venv: older releases ignore PIPENV_NO_VENV_IN_PROJECT just as they ignore the Pipfile key, so with no ./.venv the WORKON_HOME venv is now found for that variable too. The test also covers each variable combined with the Pipfile key. Refs #842 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
There was a problem hiding this comment.
✅ 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 4136270. Configure here.
|
Burn-down agent: labeled Ready for review.
Slack announcement not sent this run (no Slack send tool available); the next run will retry. Generated by Claude Code |
Final review briefWhat it does: If a Pipfile sets Risk: low. It is a one-condition change in Python venv discovery. The worst case is on Pipenv 2026.2+ with the key set, no Look here:
Verified:
Changes I made: none. Open questions: none. Auto-merge (squash) is armed, so approving sends this straight to the merge queue. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #842
Summary
Some projects commit
[pipenv] venv_in_project = truein the Pipfileand have no
./.venv. On Pipenv 2018.11 through 2026.1, socket-patchmissed the venv Pipenv really uses (
$WORKON_HOME/<name>-<hash>).Agent
scanthen skipped the installed package as "not installed",exited 0 and left the venv unpatched. Hosted
scanlost itsstale-install warning for the warm venv. Both modes now find that venv.
Root cause
pipenv_settings_site_packages(crates/socket-patch-core/src/crawlers/python_crawler.rs)read any explicit "in project" choice plus a missing
./.venvas"Pipenv has no venv yet" and returned nothing. Only Pipenv 2026.2+ reads
the Pipfile key, so older releases still use WORKON_HOME. Both agent and
hosted discovery go through
find_local_venv_site_packages, so one fixcovers both shapes reported in the issue.
Fix
"No venv yet" now applies only when every Pipenv agrees the venv is
./.venv: a truthyPIPENV_VENV_IN_PROJECT(2018-2020 read it asbool(value), later releases parse it). If the choice comes only fromthe Pipfile key, or from
PIPENV_NO_VENV_IN_PROJECT(which old releasesalso ignore), Pipenv's own placement is looked up. That lookup returns
the WORKON_HOME venv only if it exists.
docs/testing/pipenv-compatibility.mdis updated to match.
Test evidence
python_crawler::tests::pipenv_pipfile_in_project_without_dot_venv_finds_workon_venvleft: [],right: [<wh>/proj-<hash>/lib/python3.12/site-packages]scanend to end, in-process)in_process_python_envs::pipenv_pipfile_in_project_without_dot_venv_scans_workon_venvCommands run locally on the final head:
cargo fmt --all -- --check: cleancargo clippy --workspace --all-features -- -D warnings: cleancargo test -p socket-patch-core --all-features: 6726 passed. The4 failures are permission-denial tests that can't fail when run as
root in this sandbox (
copy_treerelax loop,vlt_healunremovablelock,
pypi_poetry/pypi_requirementswire-write failure). Theyare unrelated to this change, and CI runs them as non-root.
cargo test -p socket-patch-cli --all-features --lib --test in_process_python_envs --test in_process_redirect_pipenv --test in_process_scan --test in_process_rollback_all_ecosystems: all passcargo test --workspaceran out of this sandbox's diskallowance twice (30 GB of test binaries), so CI's run is the full
check. I didn't run the real-Pipenv
e2e_vex_build pipenv::suitelocally because it pins
PIPENV_VENV_IN_PROJECT=1, and that pathdoesn't change here. CI runs it.
Review notes (
/code-review high)PIPENV_NO_VENV_IN_PROJECT; the guardis simplified; the test now combines each variable with the Pipfile key.
./.venvyet, and a leftover WORKON_HOME venv from before, thatleftover venv is now scanned. The crawler can't tell the Pipenv
version without running it. This matches the existing policy for
./.venv+ WORKON_HOME (return both and patch whichever is used).Missing the venv older releases really use was the worse failure.
PIPENV_VENV_IN_PROJECT=0as truthy.https://claude.ai/code/session_01S1uW4TCxr9hChxXPPiYCCb
Generated by Claude Code