[R-pkg-devel] Appropriate usage of 'Suggests' -- package installed conditional on other software not found

Dirk Eddelbuettel edd @end|ng |rom deb|@n@org
Fri Oct 4 00:28:57 CEST 2019


On 3 October 2019 at 21:38, Driver, Charles wrote:
| 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.

Right.

The corrolary is that if texi2dvi fails, simply installing tinytex may not
help you either. AFAIK tinytex was primarily aimed at complementing an
existing texlive / miktex installation by noticing if any, and then which,
latex styles or fonts were missing and to then add them for the user -- which
is a good idea in principle.  I don't think it can act as a wholesale "oh you
have no (la)tex at all let's fix that in one command" magic potion.  Maybe it
does -- I just don't know as I tend to install texlive from my distro.
 
| 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.

I still get back to the basic point of (la)tex simply being optional in the
context of an R installation which is your real issue so ...
 
| 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()
|   }
| }

... while the diagnostics are right and well done, I am not sure the
suggested fix is all that helpful.  

Cheers, Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org



More information about the R-package-devel mailing list