Repository navigation
detect package-library mutations by resolving call namespaces - #18095
Conversation
The Packages pane refresh was triggered whenever console input contained a keyword like "remove" or "update" -- a regex that fired on comments, strings, and identifiers such as str_remove_all(), as well as base R's remove()/update(). On a large library (especially over NFS) the resulting library scan could hang the console for minutes (#17758). Replace the keyword regex with a two-stage check: a cheap C++ pre-filter (containsCallSyntax) that just asks whether the input contains a call, gating a precise R check (.rs.isPackageManagementCall) that parses the input and resolves each call's namespace against a strict registry of library-mutating functions. Qualified calls use the literal namespace; bare calls resolve via a search-path walk that never reads the binding value, so it cannot force a promise or re-invoke an active binding. Addresses #17758.
🍎 macOS Desktop E2E · ARM64✅ All tests passed!
📥 Download Playwright report⬇️ playwright-report.zip — extract and open
2 shards · macos-26 ARM64 · commit |
🐧 Linux Server E2E · Ubuntu 24❌ 1 test(s) failed
📥 Download Playwright report⬇️ playwright-report.zip — extract and open
2 shards · ubuntu-24.04 · commit |
🐧 Linux Desktop E2E · Ubuntu 24✅ All tests passed!
📥 Download Playwright report⬇️ playwright-report.zip — extract and open
2 shards · ubuntu-24.04 · commit |
🪟 Windows Desktop E2E · Server 2025 x64✅ All tests passed!
📥 Download Playwright report⬇️ playwright-report.zip — extract and open
2 shards · Windows Server 2025 x64 · commit |
Summary
The Packages pane refresh was triggered whenever console input merely contained a keyword like
removeorupdate. The detection was a substring/keyword regex, so it fired on comments, strings, and identifiers such asstr_remove_all(), as well as base R'sremove()(object removal) andupdate()(model refit). Each false positive kicked off a full installed-package scan, which on a large library served over NFS could hang the console for minutes (the session entering uninterruptibleDstate) -- see #17758.Approach
Replace the keyword regex with a two-stage check:
containsCallSyntax) -- a deliberately dumb regex that only asks "does this input contain a function call?". It carries no package knowledge, so there is no keyword list to keep in sync..rs.isPackageManagementCall) -- parses the input and, for each call, resolves its namespace against a strict per-namespace registry of library-mutating functions (utils,renv,pak,pacman,remotes,devtools,BiocManager). Namespace-qualified calls (renv::update()) use the literal namespace; bare calls resolve via a search-path walk.The bare-call resolver never reads the binding's value (no
get(), no mode matching) -- it only tests for the binding's presence and uses the providing environment's name. That keeps it from forcing a promise (delayedAssign) or re-invoking an active binding as a side effect, and it never scans the package library.As a result,
base::remove()/stats::update()are ignored because of what they resolve to, while genuine package operations (install.packages(),remove.packages(),renv::update(), ...) still refresh the pane.Testing
SessionPackagesTest) updated to cover the pre-filter; pass.src/cpp/tests/testthat/test-packages.Rcovers qualified/unqualified resolution, base-R disambiguation, comments/strings, multi-statement and nested calls, unparseable input, and the active-binding / promise side-effect-safety guarantees (45 expectations, all passing).Fixes #17758.