2

I use R/exams to generate a PDF exam like this:

exams2pdf("swisscapital")

However, this results in the following error:

Loading required namespace: tinytex
sh: : Permission denied

Doing the same with exams2html() works well.

What is the problem and how can I fix it?

Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49
uzsolt
  • 5,832
  • 2
  • 20
  • 32
  • I cannot replicate this - at my end everything runs fine. Can you please add some more context: Is this caused by `latexmk()` from `tinytex`? Does `exams2pdf("swisscapital")` produce the same error? Does `exams2html()` work on your exercise? Does `latexmk()` work on other files? For the latter you could test: `utils::Sweave(system.file("Sweave", "Sweave-test-1.Rnw", package = "utils"))` to produce a .tex from the .Rnw and then `tinytex::latexmk("Sweave-test-1.tex")` to compile it to PDF. – Achim Zeileis Jun 03 '20 at 21:39
  • The `exams2pdf("swisscapital")` returns same error. The `utils::Sweave(system.file...)` works well: appears the `.tex` file and can compile it with `tinytex::latexmk` (and appears a `.pdf`). – uzsolt Jun 04 '20 at 04:22
  • One more information: I've many `.Rnw` files and created one big `pdf` with `exams2pdf` (with `file=list.files(...` option). I rewrite `files=one.Rnw` and it doesn't work - and everything else too. I don't know what I did between them which causes the error. See my edit in the question. – uzsolt Jun 04 '20 at 04:35
  • If `exams2pdf("swisscapital")` produces the same error, please simplify your question accordingly. Then we don't have to deal with extra files, encodings, etc. And I presume `exams2html("swisscapital")` works? Or does it have the same error? What is the `traceback()` of the error? Does it still occur when you compile the PDF file in the current working directory: `exams2pdf("swisscapital", texdir = getwd())`? – Achim Zeileis Jun 04 '20 at 06:58
  • @AchimZeileis see my update nr2. I hope this helps. – uzsolt Jun 04 '20 at 08:56
  • No, unfortunately, this is not how `traceback()` is used. Also, convoluting the question with so many unrelated details makes it really hard to drill down to the problem. So let's focus on `exams2pdf("swisscapital")` and try to resolve this. (1) After running `exams2pdf("swisscapital")` please run `traceback()` and post the output. (2) Please also try to `exams2pdf("swisscapital", dir = ".")`. Does this produce the same error or not? (3) Please report `getOption("pdfviewer")`. Maybe just the permission for the PDF viewer is missing? – Achim Zeileis Jun 04 '20 at 20:08
  • Ah, the `pdfviewer` was the guilty (empty value). Please create an answer and I'll upvote and accept it. Thanks! – uzsolt Jun 05 '20 at 13:25
  • OK, good. I edited the question and removed all details that turned out to be unnecessary - in order to make it easier to find for others that have the same problem. For the same reason I also made my answer a bit more detailed than needed for you. – Achim Zeileis Jun 05 '20 at 14:32
  • Thanks for help :) – uzsolt Jun 05 '20 at 19:41

1 Answers1

2

Given that this does not produce an "error" within R but only on the shell (sh), this is probably just a problem of displaying the PDF interactively at the very end. You can check whether

getOption("pdfviewer")

is correctly set to an application for viewing PDFs (e.g., "/usr/bin/evince") and whether you have permission to use that application.

If there are problems with getting a proper PDF viewer called from within R, then simply use

exams2pdf("swisscapital", dir = ".")

which will write the PDF to your current working directory rather than displaying it in the PDF viewer. And then you can manually open the PDF outside of R.

Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49