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

Missing package handling and errors #174

Closed
3 tasks done
ngriffiths21 opened this issue Jan 3, 2020 · 2 comments
Closed
3 tasks done

Missing package handling and errors #174

ngriffiths21 opened this issue Jan 3, 2020 · 2 comments
Labels

Comments

@ngriffiths21
Copy link

When tinytex::parse_packages() fails to parse the tex log correctly, it leads to confusing errors.

For example, when I tried to compile the following test.Rmd with a fresh tinytex installation:

---
output: pdf_document
header-includes:
    - \usepackage{XCharter}
---

# Test file

This is a test

the following LaTeX error is logged:

! Package fontenc Error: Encoding file `t2aenc.def' not found.
(fontenc)                You might have misspelt the name of the encoding.

but tinytex parses it incorrectly, with an extra backtick:

> tinytex:::detect_files(" file `t2aenc.def' not found")
[1] "`t2aenc.def"

which leads tlmgr to search for '/`t2aenc.def' rather than '/t2aenc.def' and thus fail to identify the missing package.

At the very least, can the error be much clearer? e.g.:

LaTeX Error: [error from the log] (check file.log for more details).
Tinytex believes there is a missing package that contains the file "file.def"
Attempting to identify missing package automatically...
[tlmgr command]
Could not automatically identify missing package (see https://yihui.org/tinytex/#maintenance to try manually).

Inevitably, the regex will fail sometimes, which is fine. But it should be obvious that (1) it is a LaTeX error, NOT an rmarkdown or tinytex error, and (2) if tlmgr search fails, it's up to the user to figure out which package is missing.

(Also see item 2 in this answer (https://stackoverflow.com/a/58410965) for a similar situation when regex matched an error that wasn't actually a missing package).


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.

@yihui yihui added the bug label Jan 13, 2020
@yihui yihui closed this as completed in a2efe9f Jan 13, 2020
yihui added a commit that referenced this issue Jan 13, 2020
…tikz Error:" (this should get rid of the red herring in item 2 of https://stackoverflow.com/a/58410965 as mentioned in #174)
@yihui
Copy link
Member

yihui commented Jan 13, 2020

Should be fixed now. Thanks for the report!

> tinytex:::detect_files(" file `t2aenc.def' not found")
[1] "t2aenc.def"

I have made it clear that the error comes from LaTeX. I have also muted some messages by default, since they are not that useful in most cases (can be turned back on via options(tinytex.verbose = TRUE)).

The item 2 in https://stackoverflow.com/a/58410965 should also be fixed now. Thanks again!

@ngriffiths21
Copy link
Author

Great, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants