GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix global Python scan missing uv and PDM installs (#449, #451) by mikolalysenko · Pull Request #522 · SocketDev/socket-patch

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

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

Fixes #449
Fixes #451

Summary

scan -g / get -g / apply -g / rollback -g / vex -g now find:

  • uv tool envs and uv-managed Pythons wherever uv puts them, and
  • PDM's global installs.

Before this change they were silently skipped and the run still exited 0.

Root cause

get_global_python_site_packages (crates/socket-patch-core/src/crawlers/python_crawler.rs) hard-coded where Python tools keep their global environments. It didn't follow each tool's own path resolution:

  • uv (Global scan (-g) misses uv tool environments on Windows (looks in %LOCALAPPDATA%\uv\tools, uv uses %APPDATA%\uv\tools) and on every OS when UV_TOOL_DIR, XDG_DATA_HOME or UV_PYTHON_INSTALL_DIR is set #449): tool envs were scanned at %LOCALAPPDATA%\uv\tools on Windows, but uv uses %APPDATA%\uv\tools. UV_TOOL_DIR, UV_PYTHON_INSTALL_DIR and XDG_DATA_HOME were never read.
  • PDM (Global scan (-g) never crawls PDM's global project venv or PDM-managed interpreters, so pdm add -g packages are silently left out with exit 0 #451): there were no PDM entries at all.

Fix

New helpers sit next to the existing pipx_home_candidates. They return every root the tool may use, and global discovery scans the ones that exist:

  • uv_dir_candidates(home, override_var, bucket) mirrors uv's StateStore::from_settings. The candidates are:

    • $UV_TOOL_DIR / $UV_PYTHON_INSTALL_DIR, made absolute against the cwd as uv does;
    • $XDG_DATA_HOME/uv/<bucket> (absolute only);
    • ~/.local/share/uv/<bucket> on Unix;
    • %APPDATA%\uv\<bucket> on Windows;
    • the legacy roots: macOS ~/Library/Application Support/uv, and Windows %LOCALAPPDATA%\uv, which earlier releases scanned.

    I checked these rules against real uv 0.8.17 (uv tool dir / uv python dir under each env var; a relative XDG_DATA_HOME is ignored). The Windows default is the one reported in Global scan (-g) misses uv tool environments on Windows (looks in %LOCALAPPDATA%\uv\tools, uv uses %APPDATA%\uv\tools) and on every OS when UV_TOOL_DIR, XDG_DATA_HOME or UV_PYTHON_INSTALL_DIR is set #449.

  • pdm_global_site_packages(home) mirrors PDM 2.29's project/config.py and Project.__init__, plus platformdirs. It covers:

    • the global project (global_project.path, default <user_config_dir>/pdm/global-project) and its .venv;
    • an out-of-tree <venv.location>/global-project-<hash>-<py> venv;
    • the interpreter recorded in its .pdm-python (the PDM 2.12 pdm use -g case);
    • every interpreter under python.install_root (default <user_data_dir>/pdm/python).

    The settings are read from $PDM_CONFIG_FILE or <user_config_dir>/pdm/config.toml, with ~ expanded. The user dirs follow platformdirs: $XDG_CONFIG_HOME / $XDG_DATA_HOME, ~/.config / ~/.local/share on Linux, ~/Library/Application Support/pdm on macOS, and %LOCALAPPDATA%\pdm\pdm on Windows.

  • The uv tool, uv Python and pipx scans now share find_child_env_site_packages, so lib64 multilib venvs are covered for uv too.

No wrapper changes are needed: npm/, pypi/ and gem/ only dispatch the binary.

Test evidence

Tests are in crates/socket-patch-core/tests/crawler_python_e2e.rs. They pin HOME and every relocating env var, so ambient host values can't decide the result.

cargo test -p socket-patch-core --test crawler_python_e2e, Linux:

  • With this PR: 58 passed, 0 failed.
  • With python_crawler.rs reverted to main: 11 failed, which is every new Linux-applicable test.

Two more tests are Windows-only (cfg(windows)) and run on the Windows CI leg: ..._uv_tools_under_appdata and ..._uv_python_under_appdata.

Per-issue checklist:

  • Global scan (-g) misses uv tool environments on Windows (looks in %LOCALAPPDATA%\uv\tools, uv uses %APPDATA%\uv\tools) and on every OS when UV_TOOL_DIR, XDG_DATA_HOME or UV_PYTHON_INSTALL_DIR is set #449 UV_TOOL_DIR: get_global_python_site_packages_discovers_uv_tools_under_uv_tool_dir (red → green)
  • Global scan (-g) misses uv tool environments on Windows (looks in %LOCALAPPDATA%\uv\tools, uv uses %APPDATA%\uv\tools) and on every OS when UV_TOOL_DIR, XDG_DATA_HOME or UV_PYTHON_INSTALL_DIR is set #449 XDG_DATA_HOME tools: ..._discovers_uv_tools_under_xdg_data_home (red → green)
  • Global scan (-g) misses uv tool environments on Windows (looks in %LOCALAPPDATA%\uv\tools, uv uses %APPDATA%\uv\tools) and on every OS when UV_TOOL_DIR, XDG_DATA_HOME or UV_PYTHON_INSTALL_DIR is set #449 UV_PYTHON_INSTALL_DIR: ..._discovers_uv_python_under_install_dir (red → green)
  • Global scan (-g) misses uv tool environments on Windows (looks in %LOCALAPPDATA%\uv\tools, uv uses %APPDATA%\uv\tools) and on every OS when UV_TOOL_DIR, XDG_DATA_HOME or UV_PYTHON_INSTALL_DIR is set #449 XDG_DATA_HOME python: ..._discovers_uv_python_under_xdg_data_home (red → green)
  • Global scan (-g) misses uv tool environments on Windows (looks in %LOCALAPPDATA%\uv\tools, uv uses %APPDATA%\uv\tools) and on every OS when UV_TOOL_DIR, XDG_DATA_HOME or UV_PYTHON_INSTALL_DIR is set #449 Windows %APPDATA%\uv\tools / \python: ..._uv_tools_under_appdata, ..._uv_python_under_appdata (Windows CI)
  • Global scan (-g) never crawls PDM's global project venv or PDM-managed interpreters, so pdm add -g packages are silently left out with exit 0 #451 global project .venv: ..._discovers_pdm_global_project_venv (red → green)
  • Global scan (-g) never crawls PDM's global project venv or PDM-managed interpreters, so pdm add -g packages are silently left out with exit 0 #451 XDG_CONFIG_HOME: ..._discovers_pdm_global_project_under_xdg_config_home (red → green)
  • Global scan (-g) never crawls PDM's global project venv or PDM-managed interpreters, so pdm add -g packages are silently left out with exit 0 #451 PDM-managed interpreters: ..._discovers_pdm_managed_interpreters (red → green)
  • Global scan (-g) never crawls PDM's global project venv or PDM-managed interpreters, so pdm add -g packages are silently left out with exit 0 #451 global_project.path / python.install_root overrides via PDM_CONFIG_FILE: ..._follows_pdm_config_overrides (red → green)
  • Global scan (-g) never crawls PDM's global project venv or PDM-managed interpreters, so pdm add -g packages are silently left out with exit 0 #451 default config.toml: ..._reads_pdm_default_config_file (red → green)
  • Global scan (-g) never crawls PDM's global project venv or PDM-managed interpreters, so pdm add -g packages are silently left out with exit 0 #451 .pdm-python interpreter (PDM 2.12 no-venv case): ..._follows_pdm_global_project_interpreter (red → green)
  • Global scan (-g) never crawls PDM's global project venv or PDM-managed interpreters, so pdm add -g packages are silently left out with exit 0 #451 venv.location out-of-tree global venv, and other projects' venvs excluded: ..._discovers_pdm_global_project_out_of_tree_venv (red → green)

Local checks:

  • cargo clippy --workspace --all-features -- -D warnings: clean.
  • cargo test --workspace --all-features --no-fail-fast: 9,479 passed, 12 failed. Every failure is a write-failure test that makes a dir read-only with chmod, which root (this sandbox) ignores: covgap_commands_vendor ×3, in_process_redirect ×3, repair ×2, core lib ×4. The same core lib failures reproduce on unmodified main here. None of them touch the Python crawler. CI runs as a non-root user.
  • cargo fmt --all -- --check: main itself isn't rustfmt-clean with the pinned 1.93.1 toolchain, and CI doesn't run it. I formatted only the hunks this PR touches.

Review rounds

  • Bugbot (1a82a49) noted that ~ in PDM settings was expanded from HOME on Windows, while Python's expanduser uses USERPROFILE. Fixed in e5ab4b5, and the override test now covers it on Windows. Bugbot's review of e5ab4b5 found no issues.

Follow-ups

None. macOS's legacy ~/Library/Application Support/uv root is still scanned. I didn't add %APPDATA%\uv\data (the directories-crate legacy root on Windows) because I couldn't confirm uv ever used it.

🤖 Generated with Claude Code

https://claude.ai/code/session_011Y5WmyS6GcEUtn5VVPwYXu


Note

Medium Risk
Changes only global filesystem discovery paths (no patching logic), but broader scanning can include more site-packages trees and mis-resolved paths could add noise or miss edge layouts.

Overview
Global Python discovery (get_global_python_site_packages) no longer hard-codes uv install roots and now includes PDM global installs, so scan -g / get -g and related flows can see packages in those environments instead of skipping them silently.

uv (#449): Inline macOS/Windows/Linux path blocks are replaced by uv_dir_candidates, which follows uv’s layout: UV_TOOL_DIR / UV_PYTHON_INSTALL_DIR, absolute XDG_DATA_HOME, default data dirs (~/.local/share/uv, %APPDATA%\uv on Windows), plus legacy roots. Tool envs and managed interpreters are scanned via shared find_child_env_site_packages (including lib64 on Unix).

PDM (#451): New pdm_global_site_packages resolves platformdirs-style config/data dirs, reads $PDM_CONFIG_FILE or default config.toml, and surfaces site-packages for the global project (in-tree .venv, out-of-tree venv.location envs, .pdm-python interpreter) and pdm python install trees under python.install_root.

E2E tests in crawler_python_e2e.rs isolate relocating env vars (TOOL_DIR_VARS, global_site_packages_with_vars) so host settings cannot mask regressions.

Reviewed by Cursor Bugbot for commit e5ab4b5. Configure here.


Generated by Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@claude
Start fix for #449, #451
597c034
Assisted-by: Claude Code:claude-opus-5-5
This was referenced Oct 2, 2026
Global scan (-g) misses uv tool environments on Windows (looks in %LOCALAPPDATA%\uv\tools, uv uses %APPDATA%\uv\tools) and on every OS when UV_TOOL_DIR, XDG_DATA_HOME or UV_PYTHON_INSTALL_DIR is set #449
Closed
Global scan (-g) never crawls PDM's global project venv or PDM-managed interpreters, so pdm add -g packages are silently left out with exit 0 #451
Closed
@claude
Find uv and PDM global installs in -g scans
1a82a49
scan -g, get -g, apply -g, rollback -g and vex -g looked for uv tool
envs and uv-managed Pythons only at fixed paths, and never looked for
PDM's global installs at all. On Windows every uv tool env was missed
(uv uses %APPDATA%, not %LOCALAPPDATA%). On every OS, UV_TOOL_DIR,
UV_PYTHON_INSTALL_DIR and XDG_DATA_HOME were ignored. `pdm add -g`
packages in the global project venv, and packages in PDM-managed
interpreters, were silently left out.

Global discovery now follows each tool's own path rules: uv's
override env vars and state dir, and PDM's platformdirs config/data
dirs plus the global_project.path, python.install_root and
venv.location settings and the global project's .pdm-python.

Fixes #449
Fixes #451

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

Mikola Lysenko (mikolalysenko) commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Oct 2, 2026
View reviewed changes

@cursor cursor Bot left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread crates/socket-patch-core/src/crawlers/python_crawler.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@claude
Expand PDM's ~ from USERPROFILE on Windows
e5ab4b5
PDM expands a `~` in global_project.path or python.install_root with
Python's expanduser, which uses USERPROFILE on Windows and ignores
HOME. Under Git Bash, HOME is an MSYS path, so the relocated global
project or interpreter root was looked for in the wrong place.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

cursor[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Oct 2, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 e5ab4b5. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

[agent] Ready for review at e5ab4b5.

  • CI: all 340 check runs have finished: 334 passed, 6 skipped, none failed.
  • Bugbot: its one finding on 1a82a49 (Windows ~ expansion) is fixed and resolved. Its review of e5ab4b5 found no new issues.
  • Every new Linux-applicable regression test fails when python_crawler.rs is reverted to main (11 of the 58 tests in the file).

Generated by Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Mikola Lysenko (mikolalysenko) commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

[burn-down agent] Labeled Ready for review at e5ab4b5d47.

  • CI: 340/340 check runs finished on the head, none failed (success, skipped, or neutral).
  • Bugbot: reviewed e5ab4b5d47, no new issues. No unresolved review threads.
  • Mergeable against main. Still needs a human approval.

Generated by Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mikolalysenko Mikola Lysenko (mikolalysenko) mentioned this pull request Oct 2, 2026
Fix PyPI agent apply patching only one installed copy (#529, #501) #538
Merged
2 tasks done
Tanmay182003
Tanmay Singla (Tanmay182003) approved these changes Oct 2, 2026
View reviewed changes
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed e5ab4b5d47d51f534464b43bda48bd303b12ba27. Recommendation: ready to merge as-is from code review.

No actionable regressions found in the global uv/PDM discovery changes. Checked relocated roots, platform branches, PDM config/interpreter resolution, regular-file reads, and lib64 handling.

Validation: cargo test -p socket-patch-core --test crawler_python_e2e — 59 passed on macOS, including the new relocation and PDM cases. Windows-only APPDATA cases and full workspace were not rerun.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mikolalysenko
Mikola Lysenko (mikolalysenko) merged commit e4d8ad5 into main Oct 2, 2026
340 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-python-global-tool-roots branch October 2, 2026 14:28
@mikolalysenko Mikola Lysenko (mikolalysenko) mentioned this pull request Oct 2, 2026
Global scan (-g) ignores PDM's site-wide config, so a global project relocated in /etc/xdg/pdm/config.toml is never crawled and get -g reports "applied" while the copy PDM runs stays unpatched #566
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cursor cursor[bot] cursor[bot] left review comments
@Tanmay182003 Tanmay Singla (Tanmay182003) Tanmay182003 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Global scan (-g) never crawls PDM's global project venv or PDM-managed interpreters, so pdm add -g packages are silently left out with exit 0 Global scan (-g) misses uv tool environments on Windows (looks in %LOCALAPPDATA%\uv\tools, uv uses %APPDATA%\uv\tools) and on every OS when UV_TOOL_DIR, XDG_DATA_HOME or UV_PYTHON_INSTALL_DIR is set

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mikolalysenko @Tanmay182003 @claude
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.