Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in : Failed to compile #143

Closed
3 tasks done
shiny23 opened this issue Sep 9, 2019 · 4 comments
Closed
3 tasks done

Error in : Failed to compile #143

shiny23 opened this issue Sep 9, 2019 · 4 comments

Comments

@shiny23
Copy link

shiny23 commented Sep 9, 2019

This is the link to my question on SO.

In this question on SO, I was trying to pass table and plots as parameters to Shiny app, I tried the answer

Reproducbile example:

report.Rmd

---
title: "Dynamic report"
output: pdf_document
params:
  plotData: NA
  tableData: NA
  plotCode: NA
---

```{r}
params$tableData
```
```{r}
eval(parse(text = params$plotCode))
```

```{r}
library(ggplot2)
ggplot(params$plotData, aes (x = carat, y = price, col = color)) +
  geom_point() +
  facet_wrap(~cut)
```

App.R

library(shiny)
library(tidyverse)
library(rmarkdown)
library(tinytex)

df <-  diamonds[1:5000, ]
head(df)
write.csv(df, "df.csv")

#setwd("....") #be sure to be in same directory
shinyApp(
  ui = fluidPage(
    sliderInput(inputId = "slider", label = "Slider", min = 1, max = 100, value = 50),
    fileInput(inputId = "file", label = "Upload your file"),
    downloadButton(outputId = "report", label = "Generate report")
  ),
  server = function(input, output) {
    data <- reactive({
      file1 <- input$file
      if(is.null(file1)){return()}
      read.csv(file1$datapath, header = TRUE, sep = ',')
    })

    table_rmd <- reactive({
      data() %>% 
        dplyr::select(cut, color, price) %>% 
        dplyr::group_by(cut, color) %>% 
        dplyr::summarise_all(funs(min(.), mean(.), median(.),max(.),sd(.), n() )) 
    })


    output$report <- downloadHandler(
      filename = "report.pdf",
      content = function(file) {

        tempReport <- file.path(tempdir(), "report.Rmd")
        file.copy("report.Rmd", tempReport, overwrite = TRUE)

        params <- list(plotData = data(), tableData = table_rmd(), plotCode = "plot(1)")

        rmarkdown::render(tempReport, output_file = file,
                          params = params,
                          envir = new.env(parent = globalenv())
        )
      }
    )
  }
)

but it resulted in the following error. I wonder what caused it and how it can be fixed

processing file: report.Rmd
  |.........                                                        |  14%
  ordinary text without R code

  |...................                                              |  29%
label: unnamed-chunk-1
  |............................                                     |  43%
  ordinary text without R code

  |.....................................                            |  57%
label: unnamed-chunk-2
  |..............................................                   |  71%
  ordinary text without R code

  |........................................................         |  86%
label: unnamed-chunk-3
  |.................................................................| 100%
  ordinary text without R code


output file: report.knit.md

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS report.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandocc4033995e35.tex --template "C:\PROGRA~1\R\R-35~1.2\library\RMARKD~1\rmd\latex\DEFAUL~3.TEX" --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes" 
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/W32TeX) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
Warning: Error in : Failed to compile C:\Users\user\AppData\Local\Temp\RtmpGGSIIf\filec402524ea2.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips.
  [No stack trace available]

Here is xfun::session_info('tinytex')

R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1, RStudio 1.2.1335

Locale:
  LC_COLLATE=English_New Zealand.1252  LC_CTYPE=English_New Zealand.1252    LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C                        
  LC_TIME=English_New Zealand.1252    

Package version:
  graphics_3.5.2  grDevices_3.5.2 stats_3.5.2     tinytex_0.15.2  tools_3.5.2     utils_3.5.2     xfun_0.9  

Additional info based on this issue

> (function() {
+     tinytex:::tweak_path()
+     print(Sys.which('pdflatex'))
+     system2('pdflatex', '--version')
+ })()
                                                                     pdflatex 
"C:\\Users\\user\\AppData\\Roaming\\TinyTeX\\bin\\win32\\pdflatex.exe" 
pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019/W32TeX)
kpathsea version 6.3.1
Copyright 2019 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.36; using libpng 1.6.36
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.01
> p = tinytex:::win_app_dir('TinyTeX', 'bin', 'win32', 'tlmgr.bat')
> p
[1] "C:\\Users\\user\\AppData\\Roaming/TinyTeX/bin/win32/tlmgr.bat"
> file_test('-x', p)
C:\\Users\\user\\AppData\\Roaming/TinyTeX/bin/win32/tlmgr.bat 
                                                                TRUE 

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.name/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('tinytex'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/tinytex').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@cderv
Copy link
Contributor

cderv commented Sep 9, 2019

Hi,

You did not filled the issue template (that you left at the bottom of your post) and we are missing a few pieces like a reproductible example. Currently with these informations, it is difficult to know what is going on.

Did you follow the advice given in your error by following https://yihui.name/tinytex/r/#debugging ?
I think this should print more informations on what is going on. Having log from Latex conversion to pdf should help.
Thank you.

@shiny23
Copy link
Author

shiny23 commented Sep 11, 2019

Hi, Many thanks. Please check the updated question. I have filled the issue template. Thanks for your time and help.

@shiny23
Copy link
Author

shiny23 commented Sep 11, 2019

I just uninstalled TinyTex and installed MiKTex and everything is working fine now. I don't understand why.

@yihui
Copy link
Member

yihui commented Mar 31, 2020

The debugging section at https://yihui.org/tinytex/r/#debugging told you to set options(tinytex.verbose = TRUE) and retry. If you did that, it should reveal more information about the failure. Without the information, it is hard to tell what was going on...

@yihui yihui closed this as completed Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants