[Rd] R package builder silently continues after unclosed brace

Gábor Csárdi c@@rd|@g@bor @end|ng |rom gm@||@com
Sat Jan 25 21:55:16 CET 2020


R CMD build does not actually run any R code, it just puts the files
together into a .tar.gz archive.

R CMD INSTALL will run the R code, and fail.

Gabor

On Sat, Jan 25, 2020 at 4:59 PM Andy Manka <andy.manka using gmail.com> wrote:
>
>
> If you start a function in one file but don't close it, the package
> will still build if you manage to close it in a later file. Like so:
>
> a.R
> b.R
> c.R
>
> a.R:
> function_a <- function(){
>   print("this is function_a")
> }
>
> b.R:
> function_b <- function(){
>   print("unclosed function_b")
> # no closing }
>
> c.R:
> function_c <- function(){
>   print("function_c will be part of function_b")
> }
> #extra closing } to close function_b
> }
>
> --------
>
> The package builder will import `a.R` and `b.R`. And because
> function_b was never closed, `c.R` gets subsumed into function_b. It's
> pretty hard to debug, and it means that a production implementation
> depends on the file structure never changing. (If you define a
> function across `b.R` and `d.R`, you can never add an R script that
> starts with `c`.)
>
> What's the benefit of letting functions be defined across files in the
> package builder? Or is it an unintended side effect?
>
> I suspect the code for all this is in:
> /src/library/tools/R/build.R
>
> but it's beyond me.
>
> The command I ran is:
> "C:\Program Files\R\R-3.6.2\bin\x64\Rcmd.exe" build "c:\path\to\package"
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list