miniCRAN icon indicating copy to clipboard operation
miniCRAN copied to clipboard

Create a 'removePackages' function to easily remove packages from the miniCRAN repo

Open paulponcet opened this issue 7 years ago • 6 comments

paulponcet avatar Dec 10 '16 16:12 paulponcet

Please provide more information about the specific nature of your request.

For example:

  • What do you want to happen with dependencies and reverse dependencies of the removed package?
  • What is the use case for deleting a package, compared to simply recreating the miniCRAN repo?

The workaround is simple:

  • Delete the package
  • Rebuild the index file

Pull requests welcome.

andrie avatar Dec 12 '16 12:12 andrie

A use case may happen for instance when one package inside a miniCRAN repo is accepted on CRAN.

Would you consider the following function as a good candidate for a pull request - up to dependencies or reverse dependencies management? (In the end it would better be called deletePackage rather than removePackage to avoid any detrimental confusion with remove.packages)

deletePackage <- function(pkgs = NULL, path = NULL, type = "source", Rversion = R.version) {
  a <- pkgAvail(repos=path, type = type, Rversion = Rversion)
  w <- which(a[,"Package"] %in% pkgs)
  ext <- switch(type, source = ".tar.gz", mac.binary = ".tgz", win.binary = ".zip")
  pkgs <- paste(a[w,"Package"], "_", a[w,"Version"], ext, sep = "")
  unlink(file.path(path, repoPrefix(type = type, Rversion = R.version), pkgs))
  updateRepoIndex(path, type = type, Rversion = Rversion)
  invisible(pkgs)
}

paulponcet avatar Dec 14 '16 22:12 paulponcet

@paulponcet the function you are proposing should be vectorized to handle multiple package types, the way addPackage does (using an lapply internally for type).

achubaty avatar Jan 09 '17 16:01 achubaty

@achubaty Came across this issue looking for the same "remove package" functionality. Would you still be interested in adding that if I vectorize the code above and send a PR?

tonytonov avatar Mar 28 '19 09:03 tonytonov

@tonytonov Vectorizing the code is a good start but Andrie's points above still hold. For me, I would want unused dependencies to also be removed. PRs welcome!

achubaty avatar Mar 28 '19 15:03 achubaty

@achubaty @andrie You have probably seen it, but is there any chance you could review the PR in the near future? I'm afraid soon I'll completely forget what I've coded there.

tonytonov avatar Jun 25 '19 08:06 tonytonov