4

I randomly started getting the error messages below while trying to run a RMarkdown document. I am on a Windows, so I deleted the TinyTex subfolder within the AppData folder and reran tinytex::install_tinytex(). That installed but didn't fix the error messages, so I tried tinytex::reinstall_tinytex() but that didn't help.

I know from the error messages I am missing LaTeX packages, so I tried running the code below but it will not run. I assume there is a greater problem at hand, and guidance would be greatly appreciated.

tinytex::parse_install(text = "! LaTeX Error: File `setspace.sty' not found.")

Error messages:

A new version of TeX Live has been released. If you need to install or update any LaTeX packages, you have to upgrade TinyTeX with tinytex::reinstall_tinytex(). If it fails to upgrade, you might be using a default random CTAN mirror that has not been fully synced to the main CTAN repository, and you need to wait for a few more days or use a CTAN mirror that is known to be up-to-date (see the "repository" argument on the help page ?tinytex::install_tinytex).

tlmgr.pl: Local TeX Live (2021) is older than remote repository (2022). Cross release updates are only supported with update-tlmgr-latest(.sh/.exe) --update See https://tug.org/texlive/upgrade.html for details. ! LaTeX Error: File `setspace.sty' not found.

! Emergency stop. <read *>

Error: LaTeX failed to compile markdown.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See markdown.log for more info. Execution halted

Daniel L
  • 158
  • 1
  • 8
  • I don't understand the logic in trying to parse an error message for the purpose of installation. Why not investigate the right way to install the `setspace.sty` file? – IRTFM Apr 04 '22 at 16:02
  • @IRTFM I was just experimenting using https://bookdown.org/yihui/rmarkdown-cookbook/install-latex-pkgs.html. If you have a link on the right way to install sty files, that would be nice, but I don't think that is the main issue at hand. – Daniel L Apr 04 '22 at 16:05

2 Answers2

1

Two possibilities:

  1. set your mirror to the historic version which still has 2021, e.g.

    tinytex::tlmgr("option repository https://ftp.tu-chemnitz.de/pub/tug/historic/systems/texlive/2021/tlnet-final")
    
  2. install vanilla texlive2022 from https://tug.org/texlive/

(I'd go with the second solution. If you use a complete texlive installation instead of tinytex, you'll never again have to deal with missing packages)

  • After installing texlive2022, what next steps need to be taken so I can knit a pdf? – Daniel L Apr 04 '22 at 16:46
  • @DanielL You need to add the new location of latex to your path. How to do this will depend where you use R. Either modify the path in your shell if you use it from the command line or add the path to your `~/.Renviron` file if you use rstudio `PATH=/usr/local/texlive/2022/bin/universal-darwin/:$PATH` (adjust the syntax to your shell and architecture as necessary) – samcarter_is_at_topanswers.xyz Apr 04 '22 at 16:53
1

The error messages above should no longer appear for anyone who is trying to knit a pdf with RMarkdown based on the feed at https://github.com/yihui/tinytex/issues/293. TeX Live released their 2022 version on April 3, so there is a window of time where tinytex needs to update.

One could also use @samcarter_is_at_topanswers.xyz recommendations and install TeX Live 2022 themselves (https://tug.org/texlive/acquire-netinstall.html), and update their path within RStudio (How to teach R find the texlive directory when using rstudio?).

Daniel L
  • 158
  • 1
  • 8