[R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found
Driver, Charles
dr|ver @end|ng |rom mp|b-ber||n@mpg@de
Thu Oct 3 23:38:40 CEST 2019
Thanks for the thoughts all. In some ideal world I agree a simple message and leave it up to the user would be cleanest, in a world where I / others already have to deal with random compiler problems and other excitement in the middle of teaching workshops, I can see the benefits of an optional 'take care of it for me please' step.
I don't really see why this should be problematic / unappealing, if only asked during interactive sessions.
Since texi2dvi does more advanced checking than my simple Sys.which('pdflatex') , it sounds like I should rely on an error from that as cause for the message / prompt.
html / Mathjax was quite a pain for the matrix notation, so the kids are still stuck with latex in this case :)
While the answer seems to be 'include it in Suggests', it's still not 100% clear to me from the answers so far. The more I think on it the more I think it doesn't really make sense, since all the code in my package can run without tinytex, and it is preferable to not install tinytex unless the compile error occurs and the user desires the install.
The code would look something like this -- if the general scope is actually violating CRAN policies then sure, it doesn't matter anyway, but so far I don't see that that's the case:
hastex <- !Sys.which('pdflatex') %in% ''
a=try(tools::texi2pdf(file=paste0(filename,'.tex'),quiet=FALSE, clean=TRUE))
if('try-error' %in% class(a) && !hastex) {
message('Could not compile tex -- do you want to install tinytex? Will require a manual restart of R.')
dotiny <- readline('Y/N?')
if(dotiny %in% c('Y','y') && !requireNamespace('tinytex') ){
install.packages('tinytex')
requireNamespace('tinytex') #can perhaps leave this line out?
tinytex::install_tinytex()
}
}
Cheers,
Charles
________________________________
From: Dirk Eddelbuettel <edd using debian.org>
Sent: Thursday, October 3, 2019 5:45:20 PM
To: Fox, John
Cc: Dirk Eddelbuettel; Driver, Charles; r-package-devel using r-project.org
Subject: Re: [R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found
John,
On 3 October 2019 at 15:26, Fox, John wrote:
| In the original context of this thread, a simple error message indicating that LaTeX is absent probably would suffice.
Yes, I agree. Hence this earlier comment of mine you choose not to reply to:
| > Anyway, this is going off-topic. It might be nice for R to offer a query
| > whether 'is tex available?' just how capabilities() and extSoftVersion()
| > gives hint on some other optional capabilities (which are arguably closer to
| > its core).
That still holds because it's actually complicated -- pdflatex is a default,
but some styles require xelatex for other fonts, and there are other front
ends such as lualatex and so on.
R knows what it is doing. So if you (or Charles) look at tools::texi2dvi
(which is called by tools::texi2pdf) then you see it already tries quite a
few things to find a suitable latex drivers. Other (though IIRC not base R)
use latexmk. And the long and the short of it is that Charles probably just
wanted a Suggests: for tinytex followed by an if (requireNamespace("tinytex"))
But then "kids these days" don't care as they go from Rmd to html. Which may
be another reason not to prompt for 'pdflatex'.
Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list