Unable to generate exam with exams2moodle when including TikZ picture

197 views Asked by At

I am trying to generate exams with exams2moodle on my new laptop. Everything worked (and still works) out perfectly fine on my old laptop, but in the new one (where I have exactly the same configuration, but there's obviously something missing), even when I try to run the simplest template with a TikZ figure in R/exams exams2moodle("automaton.Rnw") I get the error message

Error in magick_image_readpath(enc2native(path), density, depth, strip, : rsession.exe: PDFDelegateFailed `El sistema no puede encontrar el archivo especificado. ' @ error/pdf.c/ReadPDFImage/809

I have checked my installation, and seen the various posts with similar problems, but haven't been able to fix it. Any idea what might be going wrong? Thank you very much in advance

EDIT: That's my session info

R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale: [1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252 LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] magick_2.4.0 mgsub_1.7.2 ICSNP_1.1-1 ICS_1.3-1 mvtnorm_1.1-1 plotrix_3.7-8
[7] Ryacas_1.1.3 FRACTION_1.0 stringr_1.4.0 Deriv_4.0.1 ggplot2_3.3.2 plot3D_1.3
[13] scatterplot3d_0.3-41 MASS_7.3-53 latex2exp_0.4.0 permute_0.9-5 mpoly_1.1.1 polynom_1.4-0
[19] pracma_2.2.9 numbers_0.7-5 exams_2.3-6

loaded via a namespace (and not attached): [1] Rcpp_1.0.5 lattice_0.20-41 tidyr_1.1.2 assertthat_0.2.1 rprojroot_1.3-2 digest_0.6.25
[7] gmp_0.6-0 R6_2.4.1 plyr_1.8.6 backports_1.1.10 survey_4.0 evaluate_0.14
[13] pillar_1.4.6 rlang_0.4.7 misc3d_0.9-0 rstudioapi_0.11 Matrix_1.2-18 rmarkdown_2.3
[19] desc_1.2.0 splines_4.0.2 partitions_1.9-22 munsell_0.5.0 tinytex_0.26 compiler_4.0.2
[25] xfun_0.17 pkgconfig_2.0.3 htmltools_0.5.0 tcltk_4.0.2 mitools_2.4 tidyselect_1.1.0
[31] tibble_3.0.3 crayon_1.3.4 dplyr_1.0.2 withr_2.3.0 grid_4.0.2 gtable_0.3.0
[37] lifecycle_0.2.0 DBI_1.1.0 orthopolynom_1.0-5 magrittr_1.5 scales_1.1.1 stringi_1.5.3
[43] testthat_2.3.2 ellipsis_0.3.1 generics_0.0.2 vctrs_0.3.4 tools_4.0.2 glue_1.4.2
[49] purrr_0.3.4 pkgload_1.1.0 survival_3.1-12 colorspace_1.4-1 knitr_1.30

1

There are 1 answers

12
Achim Zeileis On BEST ANSWER

Overview

Thanks for carefully researching the problem and reporting it here. As you already worked out, the problem is not in the code within R/exams directly but with magick::image_read() which does not work correctly in some settings. Thanks also for reporting this to Jeroen Ooms, the magick maintainer.

Bug fix in magick

In response to the issue you filed, Jeroen has updated with the magick package on GitHub with new and updated ImageMagick binaries, see: https://github.com/ropensci/magick/pull/276. Please re-install magick from GitHub which should resolve the problem.

Workaround in exams

A potential workaround that avoids using magick could be to convert the TikZ PDF output to SVG instead of PNG. In that case pdf2svg (and pdfcrop) is needed to be on the PATH (see also the comments for further details). To try it use

exams2html("automaton.Rnw", svg = TRUE)

Or with exams2moodle() instead of exams2html(). (The latter is just easier for quickly inspecting the output.)

Links