Skip to content

download_version doesn't look up duplicated package #495

Open
@kos59125

Description

@kos59125

Local CRAN repositories may have duplicated packages (same name with different versions). For example, if a repository owner uploads package PKG v1.0 and PKG 2.0 to their CRAN repository, PACKAGE in contriburl is like:

Package: PKG
Version: 1.0
Depends: anotherpkg
MD5sum: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
NeedsCompilation: no

Package: PKG
Version: 2.0
Depends: anotherpkg
MD5sum: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
NeedsCompilation: no

This is not abnormal as tools::write_PACKAGES(latestOnly = FALSE) can generate so.

The current version of download_version_url uses available.packages with default filters which means c("R_version", "OS_type", "subarch", "duplicates"). "duplicates" means it returns the latest version if duplicated packages are found (see help(available.packages)).

There are two problems. The first problem is, if users call download_version("PKG", "1.0", "https://my_local_repo") with default filters, it raises an error (if there's no Archive directory like official CRAN) because the latest version of PKG is not 1.0 but 2.0. The second problem is, if users set the available_packages_filters option like c("R_version", "OS_type", "subarch"), the user cannot download the latest version with download_version("PKG", "2.0", "https://my_local_repo").

My suggestion to resolve the problems is that download_version_url should consider the available_packages_filters option and remove "duplicates" filter. If users do not set the available_packages_filters option, the function use c("R_version", "OS_type", "subarch"). If users do set the available_packages_filters option, the function uses setdiff(user_filters, "duplicates").

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions