Skip to content
Prev 4501 / 12125 Next

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

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