r-lib / pkgbuild

Find tools needed to build R packages
https://pkgbuild.r-lib.org
Other
65 stars 33 forks source link

In build(), the dest_path= argument behaviour is not clear in the documentation, and the return value can be incorrect. #108

Closed krivit closed 2 years ago

krivit commented 3 years ago

Setting dest_path can produce two behaviours:

  1. If set to an extant directory, it will create a file in that directory with the name following the usual pattern (package, version, platform if binary).
  2. If the dest_path does not already exist or is not a directory, it will create a file with the name dest_path, containing the result.

As far as I can tell, this behaviour is not documented anywhere. Either way, the return string is a path as if it were scenario 1, which is not correct if scenario 2 is in effect.

To reproduce, run the following from the package source directory:

library(pkgbuild)
build(dest_path = "../dest1") # Create a file named "dest1" in the parent directory, with the contents of the tar.gz/zip/tgz, and return a nonexistent path.
dir.create("../dest2")
build(dest_path = "../dest2") # Create a file in ../dest2/, named according to convention, and return a path to it.
gaborcsardi commented 2 years ago

It is probably too late to change this now, so I'll document it, and fix the return value, hopefully that will not break anything.