cran4linux / bspm

R Bridge to System Package Manager
https://cran4linux.github.io/bspm
Other
80 stars 4 forks source link

Detect and report package shadowing #58

Closed Enchufa2 closed 1 year ago

Enchufa2 commented 1 year ago

Initial motivation: https://github.com/eddelbuettel/r2u/issues/30. It would be nice to have a mechanism to detect and report shadowed packages, i.e. packages that are available in several .libPaths(). In this first iteration, I devise:

  1. An exported function, e.g. bspm::shadowed_packages(), which would work as a thin wrapper around installed.packages(). It would filter its output to detect package shadowing and would return a matrix (to follow the same convention) with at least the following columns: Package, LibPath, Version, ShadowPackage, ShadowLibPath, and ShadowVersion or similar naming. Basically, the idea is that each row is a Package that is being shadowed by ShadowPackage in a ShadowLibPath with higher priority.
  2. A non-exported function that takes the output from (1) and generates one message (warning?) per row to alert the user about shadowed packages.
  3. Integration of the alert messages (with shut-off switches via options). Possible places that come to mind:
    • On bspm startup.
    • On package installation, a message/warning for packages that have another one shadowing them. This would be available only for the default slower-but-safer mode, not in the binary-source mode.
    • ...?

@eddelbuettel As always, comments welcome.

eddelbuettel commented 1 year ago

No comment with code yet, been meaning to write one for my own use (as I believe I mentioned to your prior to https://github.com/eddelbuettel/r2u/issues/30) and would (at least locally) default to sort via data.table. If and when I have something I may drop here.

The need is actually broader than bspm as you and I discussed. It can arise whenever length(.libPaths()) > 1.