Skip to content

Fix Pipenv stale-install remedy ignoring lock categories (#790) - #795

Merged
Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
agent/fix-pipenv-remedy-lock-categories
Oct 5, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
agent/fix-pipenv-remedy-lock-categories

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Fixes #790

Summary

When a warm Pipenv virtualenv still holds the unpatched release, the stale-install warning's remedy now reinstalls the package from the lock for every Pipfile.lock category. Before this change, following the printed remedy for a [dev-packages] or named-category package uninstalled it and left it uninstalled.

Root cause

The hosted redirect_pypi_stale_install and vendored pypi_pipenv_stale_install warnings printed fixed text: pipenv run pip uninstall -y <pkg> && pipenv sync or pipenv --rm && pipenv sync. Plain pipenv sync installs only default. So for a package pinned in develop or a Pipenv 2022+ named category, the remedy removed it. The --rm form also dropped every dev and category package, even for a default package.

Fix

  • New shared builder socket_patch_core::vendor::pypi_pipenv::stale_install_remedy(lock, name). Both warnings use it, so they can't drift apart again:
    • targeted (uninstall && sync): re-syncs exactly the categories that pin the package. default gives plain pipenv sync (unchanged), default/develop gives --dev, and anything with a named category gives --categories "<Pipfile names>" (packages, dev-packages, <name>);
    • clean (--rm && sync): re-syncs every non-empty category in the lock;
    • pre-2018 pipenv install --deploy gets --dev when the package is in develop. Named categories don't exist before 2022;
    • with no readable lock, it falls back to the old default-only text.
  • Hosted passes the run's final Pipfile.lock text (rewrite.files, falling back to the read files). Vendored passes the already-parsed project lock.
  • CLI_CONTRACT.md and docs/testing/pipenv-compatibility.md ("Verified remedies") describe the category-aware arguments.
  • The npm, PyPI and gem wrappers only dispatch to the binary, so they need no changes.

Per-issue checklist

Test evidence

  • Red → green. I forced stale_install_remedy to ignore the lock, which reproduces the old behaviour. All three new tests then FAILED (core: 2 failed; cli lib: 1 failed). With the fix they pass.
  • Real Pipenv check of the printed commands (project with [packages] idna, [dev-packages] attrs, [docs] six), on 2026.8.0 and 2022.12.19:
  • cargo clippy --workspace --all-features -- -D warnings: clean.
  • cargo test -p socket-patch-cli --all-features --lib --test in_process_redirect_pipenv --test in_process_vendor: 835 + 6 + 104 passed.
  • cargo test -p socket-patch-core --all-features --lib: 4844 passed, 4 failed. The 4 failures are not caused by this change. They are chmod 0o555 read-only-directory tests (copy_tree::relax_loop_must_not_traverse_symlinked_root, vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry, pypi_poetry::wire_write_failure_…, pypi_requirements::wire_failure_rolls_back_…), and they can't fail as designed when the sandbox runs as root (uid 0). CI runs as non-root.
  • Windows fix (fbdfa6f). On 77071a5, test (windows-latest) failed in vendor::pypi::tests::pipenv_stale_install_remedy_names_the_develop_category ("the upstream six.py is installed"). The test only built the POSIX lib/python3.12/site-packages layout, but the Windows venv probe reads .venv\Lib\site-packages. The test now also places the install there on Windows. The product code is unchanged.
  • Not run locally:
    • the full cargo test --workspace --all-features ran out of the sandbox's disk (target/ reached 29 GB while linking the integration test binaries). CI covers it;
    • cargo fmt --all -- --check is not clean on main itself (rustfmt 1.8.0 reformats ~130 files untouched by this PR), and CI doesn't run it. The files this PR touches were formatted hunk-by-hunk with rustfmt, so the diff carries no unrelated reformatting.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K9MfJ84pKgWnWZUoTYq8Zg


Note

Low Risk
Warning-message and documentation changes only; no redirect, vendor wiring, or install behavior is altered.

Overview
Fixes #790: stale-install warnings for Pipenv no longer tell users to run plain pipenv sync, which only reinstalls default and could leave dev or named-category packages missing after pip uninstall.

A shared stale_install_remedy(lock, name) in pypi_pipenv builds the reinstall text from Pipfile.lock: targeted pipenv sync gets --dev or --categories "…" for the sections that pin the package; pipenv --rm && pipenv sync lists every non-empty category. Hosted redirect_pypi_stale_install and vendored pypi_pipenv_stale_install both call it (hosted passes the post-rewrite lock text from the scan rewrite). Contract and Pipenv compatibility docs match the new wording. Tests cover develop, named categories, multi-section pins, and Windows venv layout.

Reviewed by Cursor Bugbot for commit fbdfa6f. Configure here.


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
When a warm Pipenv virtualenv still holds the unpatched release, the
hosted and vendored warnings told users to run `pipenv run pip
uninstall -y <pkg> && pipenv sync` or `pipenv --rm && pipenv sync`.
Plain `pipenv sync` installs only the default category, so for a
package pinned in [dev-packages] or a named category, following the
advice removed the package instead of reinstalling it patched, and the
--rm form dropped every dev and category package.

Both warnings now build the remedy from the Pipfile.lock: the targeted
form re-syncs the categories that pin the package (`--dev`, or
`--categories "<names>"`), and the --rm form re-syncs every non-empty
category.

Fixes #790

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 4, 2026 16:50
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

The develop-category regression test built only the POSIX
lib/python3.12/site-packages layout, which the Windows venv probe never
reads, so no stale install was found and the warning never fired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K9MfJ84pKgWnWZUoTYq8Zg
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for 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 fbdfa6f. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 4, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Ready for review (burn-down agent).

  • Head: fbdfa6fa73
  • CI: 485/485 check runs green on head
  • Bugbot: reviewed fbdfa6fa73, no new issues; no unresolved review threads
  • Mergeable, no conflicts (blocked only on required human approval)

Generated by Claude Code

@mikolalysenko
Mikola Lysenko (mikolalysenko) merged commit 7598020 into main Oct 5, 2026
486 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-pipenv-remedy-lock-categories branch October 5, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

3 participants