[Rd] possible bug in R CMD Rd2pdf

Duncan Murdoch murdoch.duncan at gmail.com
Wed Sep 27 13:03:09 CEST 2017


On 26/09/2017 10:27 PM, Kasper Daniel Hansen wrote:
> When I include the macros \packageAuthor, \packageDescription,
> \packageTitle, \packageMaintainer in a XX-package.Rd file, R CMD Rd2pdf
> fails with
> 
> $ R CMD Rd2pdf mpra
> Hmm ... looks like a package
> Converting Rd files to LaTeX Error : mpra/man/mpra-package.Rd:6: file
> './DESCRIPTION' does not exist
> 
> This does not happen if I comment out 4 occurrences of these 4 macros in
> mpra-package.Rd.
> 
> This is with
> 
> R Under development (unstable) (2017-09-26 r73351) -- "Unsuffered
> Consequences"
> Copyright (C) 2017 The R Foundation for Statistical Computing
> Platform: x86_64-apple-darwin16.7.0 (64-bit)
> 
> or
> 
> R version 3.4.2 RC (2017-09-26 r73351) -- "Short Summer"
> Copyright (C) 2017 The R Foundation for Statistical Computing
> Platform: x86_64-apple-darwin16.7.0 (64-bit)
> 
> and MacTex 2017.

Those errors are coming from tools:::Rd_package_author and related 
functions, because the system-defined macros call them.  Current 
definition of the \packageAuthor macro is

\newcommand{\packageAuthor}{\Sexpr[results=rd,stage=build]{tools:::Rd_package_author("#1")}}

and the function is defined as

function (pkg, dir = ".")
{
     desc <- .read_description(file.path(dir, "DESCRIPTION"))
     if (pkg != desc["Package"])
         stop(gettextf("DESCRIPTION file is for package '%s', not '%s'",
             desc["Package"], pkg))
     desc["Author"]
}

So Peter is right, this would likely work if the current working 
directory was the top level directory of the package, but it can't work 
in general.

The easiest fix would probably be to change the code underlying R CMD 
Rd2pdf so that it works from the top level directory; another 
possibility might be to come up with a better default for the "dir" 
parameter.

Duncan Murdoch



More information about the R-devel mailing list