[agent] Found by the scheduled PDM bug-hunt routine (ledger #312).
Summary
socket-patch scan -g (and SOCKET_GLOBAL=1) misses packages in the two places PDM puts global installs once a global interpreter is selected:
- The PDM global project's virtualenv.
pdm use -g <python> with a non-venv interpreter creates <user_config_dir>/pdm/global-project/.venv on PDM 2.29 (python.use_venv, the default). After that, every pdm add -g installs there (~/.config/pdm/global-project/.venv/lib/python3.X/site-packages on Linux).
- PDM-managed interpreters.
pdm python install 3.12 puts CPython under python.install_root = <user_data_dir>/pdm/python/cpython@3.12.N/ (~/.local/share/pdm/python/... on Linux). On PDM 2.12, pdm use -g with such an interpreter makes pdm add -g install straight into its lib/python3.12/site-packages.
get_global_python_site_packages() lists the system and user site dirs, Homebrew, the python.org framework, pyenv, conda, uv tools and uv-managed interpreters. It has no PDM entry, so neither location is crawled. The scan exits 0, and the missed packages are absent from the batch query.
Impact
scan -g reports nothing for these packages, so a patch for them is never surfaced. Agent-mode scan -g --mode agent, get -g, apply -g, rollback -g and vex -g resolve their site-packages through the same get_site_packages_paths() branch (python_crawler.rs:1399). From reading the code, they'd also skip these packages. I only proved the scan-discovery miss with a real install, not apply or vex. The workaround is --global-prefix <site-packages>, which does find them (see below).
The default first pdm add -g with no pdm use -g installs into the system interpreter (/usr/local/lib/python3.11/dist-packages here), and that is found. The bug needs pdm use -g or pdm python install, which is PDM's documented way to pick the global interpreter.
Repro (Linux, real PDM 2.29.2, logging mock for POST /patch/batch via SOCKET_PROXY_URL)
export HOME=$(mktemp -d) PDM_CHECK_UPDATE=false
uv venv -q pdmenv && VIRTUAL_ENV=$PWD/pdmenv uv pip install -q pdm==2.29.2; PDM=$PWD/pdmenv/bin/pdm
cd "$HOME"
$PDM python install 3.12
PY=$(ls -d $HOME/.local/share/pdm/python/cpython@3.12*/bin/python3)
$PY -m pip install iniconfig==2.0.0 # (a) package in the PDM-managed interpreter
$PDM use -g -f "$PY" # creates ~/.config/pdm/global-project/.venv
$PDM add -g idna==3.6 # (b) package in the global project venv
cd /tmp
socket-patch scan -g --ecosystems pypi --json # inspect the PURLs POSTed to /patch/batch
socket-patch scan --ecosystems pypi --json --global-prefix ~/.config/pdm/global-project/.venv/lib/python3.12/site-packages
socket-patch scan --ecosystems pypi --json --global-prefix ~/.local/share/pdm/python/cpython@3.12.14/lib/python3.12/site-packages
Output, 2 of 2 fresh runs (the mock records every PURL the CLI queries):
~/.config/pdm/global-project/.venv/lib/python3.12/site-packages/idna-3.6.dist-info
~/.local/share/pdm/python/cpython@3.12.14/lib/python3.12/site-packages/iniconfig-2.0.0.dist-info
--- scan -g
exit=0 scanned=48
matching: [] <- neither package queried
--- scan --global-prefix <global-project venv>
exit=0 scanned=5
matching: ['pkg:pypi/idna@3.6']
--- scan --global-prefix <pdm python>
exit=0 scanned=2
matching: ['pkg:pypi/iniconfig@2.0.0']
With PDM 2.12.4, pdm use -g -f <pdm-managed python3.12> followed by pdm add -g iniconfig==2.0.0 installs into cpython@3.12.14/lib/python3.12/site-packages with no venv. scan -g again doesn't query iniconfig. Running scan -g from inside the global project directory doesn't help either.
Expected vs actual
- Expected: CLI_CONTRACT.md documents
--global / -g / SOCKET_GLOBAL as "Operate on globally-installed packages". The crawler already treats uv's equivalents as global, both uv tools and uv-managed interpreters (python_crawler.rs:1250, :1296). PDM's global project venv and python.install_root interpreters are the PDM counterparts. A pdm add -g package should be discovered.
- Actual: both locations are skipped, the scan exits 0, and the user gets no hint that global PDM installs exist.
OS × PDM
| PDM |
global install location |
Linux |
macOS |
Windows |
| 2.29.2 |
default (system interpreter, no pdm use -g) |
found |
— |
— |
| 2.29.2 |
pdm use -g → global-project/.venv |
missed |
not probed |
not probed |
| 2.29.2 |
PDM-managed cpython@3.12 site-packages |
missed |
not probed |
not probed |
| 2.12.4 |
default (system interpreter) |
found |
— |
— |
| 2.12.4 |
pdm use -g <pdm-managed python> (no venv) |
missed |
not probed |
not probed |
macOS and Windows weren't probed this run, because probe branches can't currently be deleted from the routine's sandbox. From PDM's project/config.py the paths are platformdirs.user_config_path("pdm")/global-project and platformdirs.user_data_dir("pdm")/python. That is ~/Library/Application Support/pdm/... on macOS and %LOCALAPPDATA%\pdm\pdm\... on Windows, and neither is in the global list on any OS. global_project.path, python.install_root and venv.location (when venv.in_project=false) can also be overridden in PDM's config.
Suspect code
crates/socket-patch-core/src/crawlers/python_crawler.rs:1073 (get_global_python_site_packages): no PDM global project / python.install_root entries.
crates/socket-patch-core/src/crawlers/python_crawler.rs:1399: the -g branch returns only that list.
Related, for other Python tools: #415 (pipx venvs) and #449 (uv tool dirs on Windows and under env overrides).
Tested on main 2463257 (latest tag v4.0.0), release build. No first-bad bisect: the global list has never contained PDM paths.
[agent] Found by the scheduled PDM bug-hunt routine (ledger #312).
Summary
socket-patch scan -g(andSOCKET_GLOBAL=1) misses packages in the two places PDM puts global installs once a global interpreter is selected:pdm use -g <python>with a non-venv interpreter creates<user_config_dir>/pdm/global-project/.venvon PDM 2.29 (python.use_venv, the default). After that, everypdm add -ginstalls there (~/.config/pdm/global-project/.venv/lib/python3.X/site-packageson Linux).pdm python install 3.12puts CPython underpython.install_root=<user_data_dir>/pdm/python/cpython@3.12.N/(~/.local/share/pdm/python/...on Linux). On PDM 2.12,pdm use -gwith such an interpreter makespdm add -ginstall straight into itslib/python3.12/site-packages.get_global_python_site_packages()lists the system and user site dirs, Homebrew, the python.org framework, pyenv, conda, uv tools and uv-managed interpreters. It has no PDM entry, so neither location is crawled. The scan exits 0, and the missed packages are absent from the batch query.Impact
scan -greports nothing for these packages, so a patch for them is never surfaced. Agent-modescan -g --mode agent,get -g,apply -g,rollback -gandvex -gresolve their site-packages through the sameget_site_packages_paths()branch (python_crawler.rs:1399). From reading the code, they'd also skip these packages. I only proved the scan-discovery miss with a real install, not apply or vex. The workaround is--global-prefix <site-packages>, which does find them (see below).The default first
pdm add -gwith nopdm use -ginstalls into the system interpreter (/usr/local/lib/python3.11/dist-packageshere), and that is found. The bug needspdm use -gorpdm python install, which is PDM's documented way to pick the global interpreter.Repro (Linux, real PDM 2.29.2, logging mock for
POST /patch/batchviaSOCKET_PROXY_URL)Output, 2 of 2 fresh runs (the mock records every PURL the CLI queries):
With PDM 2.12.4,
pdm use -g -f <pdm-managed python3.12>followed bypdm add -g iniconfig==2.0.0installs intocpython@3.12.14/lib/python3.12/site-packageswith no venv.scan -gagain doesn't queryiniconfig. Runningscan -gfrom inside the global project directory doesn't help either.Expected vs actual
--global/-g/SOCKET_GLOBALas "Operate on globally-installed packages". The crawler already treats uv's equivalents as global, both uv tools and uv-managed interpreters (python_crawler.rs:1250,:1296). PDM's global project venv andpython.install_rootinterpreters are the PDM counterparts. Apdm add -gpackage should be discovered.OS × PDM
pdm use -g)pdm use -g→global-project/.venvcpython@3.12site-packagespdm use -g <pdm-managed python>(no venv)macOS and Windows weren't probed this run, because probe branches can't currently be deleted from the routine's sandbox. From PDM's
project/config.pythe paths areplatformdirs.user_config_path("pdm")/global-projectandplatformdirs.user_data_dir("pdm")/python. That is~/Library/Application Support/pdm/...on macOS and%LOCALAPPDATA%\pdm\pdm\...on Windows, and neither is in the global list on any OS.global_project.path,python.install_rootandvenv.location(whenvenv.in_project=false) can also be overridden in PDM's config.Suspect code
crates/socket-patch-core/src/crawlers/python_crawler.rs:1073(get_global_python_site_packages): no PDM global project /python.install_rootentries.crates/socket-patch-core/src/crawlers/python_crawler.rs:1399: the-gbranch returns only that list.Related, for other Python tools: #415 (pipx venvs) and #449 (uv tool dirs on Windows and under env overrides).
Tested on main
2463257(latest tag v4.0.0), release build. No first-bad bisect: the global list has never contained PDM paths.