daqana / tikzDevice

A R package for producing graphics output as PGF/TikZ code for use in TeX documents.
https://daqana.github.io/tikzDevice
131 stars 26 forks source link

`pdftex` fflush() failed (Bad file descriptor) #217

Open kongdd opened 1 year ago

kongdd commented 1 year ago

Dear Sir,

Could you give some clue how to solve this issue? PS: I used the tinytex as the latex engine.

library(tikzDevice)
## Example 1 ###################################
options(tikzDefaultEngine = 'pdftex')
# options(tikzDefaultEngine = 'xetex')
# options(tikzDefaultEngine = 'luatex')

td <- "."
tf <- file.path(td,'example1.tex')

# Minimal plot
tikz(tf,standAlone=TRUE)
plot(1)
dev.off()
#> png 
#>   2

# View the output
tools::texi2dvi(tf,pdf=T)
# system(paste(getOption('pdfviewer'),file.path(td,'example1.pdf')))
# setwd(oldwd)
Error in tools::texi2dvi(tf, pdf = T) : 
  unable to run pdflatex on './example1.tex'
LaTeX errors:
!pdfTeX error: pdflatex.exe (file c:/Users/kong/AppData/Roaming/TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map): fflush() failed (Bad file descriptor)
 ==> Fatal error occurred, no output PDF file produced!

Created on 2022-07-22 by the reprex package (v2.0.1)

rstub commented 1 year ago

Hmm, works for me:

library(tikzDevice)
## Example 1 ###################################
options(tikzDefaultEngine = 'pdftex')
# options(tikzDefaultEngine = 'xetex')
# options(tikzDefaultEngine = 'luatex')

td <- "."
tf <- file.path(td,'example1.tex')

# Minimal plot
tikz(tf,standAlone=TRUE)
plot(1)
dev.off()
#> png 
#>   2

# View the output
tools::texi2dvi(tf,pdf=T)
# system(paste(getOption('pdfviewer'),file.path(td,'example1.pdf')))
# setwd(oldwd)

Created on 2022-07-24 by the reprex package (v2.0.1)

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.2.1 (2022-06-23) #> os Debian GNU/Linux 11 (bullseye) #> system x86_64, linux-gnu #> ui X11 #> language en_US:en #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Berlin #> date 2022-07-24 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> backports 1.2.1 2020-12-09 [2] CRAN (R 4.0.3) #> cli 3.1.0 2021-10-27 [1] CRAN (R 4.1.2) #> crayon 1.4.0 2021-01-30 [2] CRAN (R 4.0.3) #> digest 0.6.27 2020-10-24 [2] CRAN (R 4.0.3) #> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.2) #> evaluate 0.14 2019-05-28 [2] CRAN (R 4.0.0) #> fastmap 1.1.0 2021-01-25 [2] CRAN (R 4.0.3) #> filehash 2.4-2 2019-04-17 [2] CRAN (R 4.0.2) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.1.2) #> glue 1.4.2 2020-08-27 [2] CRAN (R 4.0.2) #> highr 0.8 2019-03-20 [2] CRAN (R 4.0.0) #> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.2) #> knitr 1.31 2021-01-27 [2] CRAN (R 4.0.3) #> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.2) #> magrittr 2.0.1 2020-11-17 [2] CRAN (R 4.0.3) #> pillar 1.4.7 2020-11-20 [2] CRAN (R 4.0.3) #> pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 4.0.0) #> purrr 0.3.4 2020-04-17 [2] CRAN (R 4.0.0) #> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.2) #> R.methodsS3 1.8.1 2020-08-26 [2] CRAN (R 4.0.2) #> R.oo 1.24.0 2020-08-26 [2] CRAN (R 4.0.2) #> R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.2) #> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.2) #> rlang 0.4.10 2020-12-30 [2] CRAN (R 4.0.3) #> rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.1.2) #> rstudioapi 0.13 2020-11-12 [2] CRAN (R 4.0.3) #> sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 4.0.0) #> stringi 1.5.3 2020-09-09 [2] CRAN (R 4.0.2) #> stringr 1.4.0 2019-02-10 [2] CRAN (R 4.0.0) #> styler 1.6.2 2021-09-23 [1] CRAN (R 4.1.2) #> tibble 3.0.6 2021-01-29 [2] CRAN (R 4.0.3) #> tikzDevice * 0.12.3.1 2020-06-30 [1] CRAN (R 4.2.1) #> vctrs 0.3.6 2020-12-17 [2] CRAN (R 4.0.3) #> withr 2.4.1 2021-01-26 [2] CRAN (R 4.0.3) #> xfun 0.28 2021-11-04 [1] CRAN (R 4.1.2) #> yaml 2.2.1 2020-02-01 [2] CRAN (R 4.0.0) #> #> [1] /usr/local/lib/R/site-library #> [2] /usr/lib/R/site-library #> [3] /usr/lib/R/library ```

Are you sure you can process LaTeX documents that do not make use of tikzDevice? Can you please send the output of tikzDevice::tikzTest()?

alasorous commented 1 year ago

Hi, did you resolve this issue? I have the same issue.

The output of tikzDevice::tikzTest() is

tikzDevice::tikzTest()
#> 
#> Active compiler:
#>  C:\Users\AGO~1\AppData\Roaming\TinyTeX\bin\win32\pdflatex.exe
#>  pdfTeX 3.141592653-2.6-1.40.24 (TeX Live 2022)
#>  kpathsea version 6.3.4
#> Measuring dimensions of: A
#> Running command: "C:\Users\AGO~1\AppData\Roaming\TinyTeX\bin\win32\pdflatex.exe" -interaction=batchmode -halt-on-error -output-directory "C:\Users\AGO~1\AppData\Local\Temp\Rtmp6ZFyCH\tikzDevice1ab059b944cb" "tikzStringWidthCalc.tex"
#> [1] 7.49817

Created on 2022-08-05 by the reprex package (v2.0.1)

rstub commented 1 year ago

I haven't heard from @kongdd, so not sure if they were able to solve this.

As for your issue:

kongdd commented 1 year ago

Thank you @rstub.
Sorry for the later response. I found it might be the problem of tinytex.

When I change to WSL, everything is fine.

alasorous commented 1 year ago

Thanks for your help. I tried using MiKTeX instead of Tinytex and it worked.

rstub commented 1 year ago

Thanks for the feedback. I might get back to you once I have a better Windows set-up to test this. After all, using TinyTeX should also work out of the box.