miniCRAN icon indicating copy to clipboard operation
miniCRAN copied to clipboard

Incorrect identification of packages with checkVersions()

Open jwood000 opened this issue 3 years ago • 2 comments

While I was checking the versions in my repo with checkVersions, I was a bit surprised because I had done a good bit of processing to ensure there were no duplicates. After manually checking myRepo/src/contrib and confirming there were no duplicates, I investigated the source of checkVersions.

miniCRAN::checkVersions
function (pkgs = NULL, path = NULL, type = "source", Rversion = R.version) 
{
    if (is.null(path)) 
        stop("path must be specified.")
    if (!file.exists(path)) 
        stop("invalid path, ", path)
    do_one <- function(type) {
        pkgPath <- repoBinPath(path, type, Rversion)
        if (is.null(pkgs)) {
            files <- dir(pkgPath)
        }
        else {
            files <- sapply(pkgs, function(x) list.files(pkgPath, 
                pattern = paste0(x, "_")))
        }
        files <- unlist(files)

The line below is troublesome.

files <- sapply(pkgs, function(x) list.files(pkgPath, 
                pattern = paste0(x, "_")))

Take for example, the package ps. The above line, will pick up any package ending in "ps" (e.g. bitops, leaps, maps, etc.). Later on, files is unlisted and of course, duplicates are found because they have already been included.

The good news is that the fix is simple. All we need to do is add ^ like so:

files <- sapply(pkgs, function(x) list.files(pkgPath, 
                pattern = paste0("^", x, "_")))

Cheers and thanks for the great package!

jwood000 avatar Sep 17 '20 19:09 jwood000

indeed, that looks like a very simple and correct fix to the problem you describe. are you able to create a pull request?

achubaty avatar Sep 17 '20 19:09 achubaty