shiny apps + pandoc/latex issue?

196 views
Skip to first unread message

Gianluca Baio

unread,
Apr 28, 2016, 6:11:51 AM4/28/16
to Shiny - Web Framework for R
Apologies if this is a known issue/solution,  but I can't seem to find any pointers...

I've just deployed my apps to the shinyapps.io server. All works fine (no errors at deploy and all functionalities/calculations work fine). However, part of the app is to use rmarkdown to produce either a pdf (via latex) or word report with a summary of the analyses. When I try this locally (on several computers/laptops) all works OK. But from the webapp, if I try to create the pdf report I get this erro message in the log:
Error in if (version >= "1.15.2") latex_template <- "default-1.15.2.tex" else if (version >=  : argument is of length zero

Also, if I try to use the docx version of the report, the error message is
Error : pandoc version 1.12.3 or higher is required and was not found.

I'm guessing this may have to do with pandoc not being updated in the shinyapps.io server, but I'm not sure I'm missing something else that is actually obvious...

Any help appreciated.

Thanks
Gianluca

Tareef Kawaf

unread,
Apr 29, 2016, 12:52:41 PM4/29/16
to Shiny - Web Framework for R
Gianluca,
Can you share the part of the code that you use to generate the output?  are you trying to call pandoc directly or are you using rmarkdown's rendering capabilities?

Gianluca Baio

unread,
Apr 29, 2016, 3:57:09 PM4/29/16
to Shiny - Web Framework for R
Thank you, Tareef.
I'm using the rmarkdown command, something like:
render('report.Rmd', switch(input$format, PDF = pdf_document(), Word = word_document()))
(I think this was an issue raised somewhere --- but we were always doing this anyway)...

Thanks
G

Tareef Kawaf

unread,
Apr 29, 2016, 4:40:16 PM4/29/16
to Gianluca Baio, Shiny - Web Framework for R
Thanks Gianluca,
I will forward your example on to the team.  Hopefully they can see what is going on.

-Tareef

--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/sFXBhPZhyK0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/1147cd2a-dc35-461e-a5a8-cba2a20c89d8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Gianluca Baio

unread,
May 4, 2016, 2:07:20 PM5/4/16
to Shiny - Web Framework for R, gia...@gmail.com
Hi all,
I'm assuming there's no news on this?

Thanks
Gianluca

Tareef Kawaf

unread,
May 4, 2016, 2:44:55 PM5/4/16
to Gianluca Baio, Shiny - Web Framework for R
I believe that Yihui has checked in a fix for this on the latest version of R Markdown, but I don't have all the details.  Hopefully he can chime in to confirm/deny.

Joe Cheng

unread,
May 4, 2016, 2:48:46 PM5/4/16
to Tareef Kawaf, Gianluca Baio, Shiny - Web Framework for R
Are you overwriting the RSTUDIO_PANDOC environment variable in your R code, or .Renviron, or anywhere else?

You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/CAMYk84zJJ2QThbc63Rk0UxtvZZh%2B6gLUKMWC6QW_0uXf2_FTdQ%40mail.gmail.com.

Yihui Xie

unread,
May 4, 2016, 2:51:10 PM5/4/16
to Gianluca Baio, Shiny - Web Framework for R, Tareef Kawaf
I checked in a fix to clarify the error message:
https://github.com/rstudio/rmarkdown/pull/688 I cannot fix your
problem because I heard it was basically a user error, i.e. you set
the environment variable RSTUDIO_PANDOC to a wrong directory in your
app. You should not need to manipulate this environment since Shiny
Server will automatically set it to the correct location. If you
modify it, you should know what it means.

If your app does not work without setting RSTUDIO_PANDOC, that is
likely to be our problem, and we can definitely investigate it.

Regards,
Yihui

Gianluca Baio

unread,
May 4, 2016, 4:11:01 PM5/4/16
to Yihui Xie, Shiny - Web Framework for R, Tareef Kawaf
Thank you all. I think we did change the code and possibly messed up by setting RSTUDIO_PANDOC to the wrong directory. But I also think that it wasn't working when it was not set explicitly: I've just re-deployed the app after commenting out the line about redefining the PANDOC directory and I still get the error
pandoc version 1.12.3 or higher is required and was not found.
when trying to download the .docx file or 
argument is of length zero
when trying the pdf...

Many thanks
Gianluca 

Yihui Xie

unread,
May 4, 2016, 4:49:19 PM5/4/16
to Gianluca Baio, Shiny - Web Framework for R, Tareef Kawaf
Please devtools::install_github('rstudio/rmarkdown') so you won't get
the confusing error message "argument of length zero".

I cannot reproduce your issue on ShinyApps.io with this example:
https://yihui.shinyapps.io/016-knitr-pdf/ Source:
https://github.com/rstudio/shiny-examples/tree/master/016-knitr-pdf

Regards,
Yihui

Gianluca Baio

unread,
May 5, 2016, 9:13:00 AM5/5/16
to Shiny - Web Framework for R, gia...@gmail.com, tar...@rstudio.com
Thanks Yihui,
I've accidentally upgraded R to 3.3 last night, so I don't think I can deploy my app just yet (I was having the same problem when I upgraded to 3.2.5 a few weeks back), so can't test this. But would it be a problem that we hadn't put the lines
owd <- setwd(tempdir())
      on.exit(setwd(owd))
      file.copy(src, 'report.Rmd', overwrite = TRUE)
and that we were using 
file.copy(out, file)
instead of 
file.rename(out, file)
?
BW
Gianluca

Yihui Xie

unread,
May 12, 2016, 1:15:40 AM5/12/16
to Gianluca Baio, Shiny - Web Framework for R
I did setwd(tempdir()) only to make sure the directory is writable.
Your app directory might not be writable. It might be, but I haven't
tested it. If you do have write permission in the app directory, there
is no need to make a copy of the Rmd to the temporary directory and
compile it to PDF there.

Regards,
Yihui
> You received this message because you are subscribed to the Google Groups
> "Shiny - Web Framework for R" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to shiny-discus...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/shiny-discuss/9dc27f31-9019-42a8-8c3e-c2e769fa8aad%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages