'When knit out R cmd file, error said "! LaTeX Error: File `fancyhdr.sty' not found. "

I have tried:

Follow https://yihui.org/tinytex/r/

  1. update.packages(ask = FALSE, checkBuilt = TRUE) tinytex::tlmgr_update() --> NOT WORK

  2. tinytex::reinstall_tinytex()--> NOT WORK

  3. --> NOT WORK

library(tidyverse)
library(vitae)
knitr::opts_chunk$set(echo = FALSE)
options(tinytex.verbose = TRUE)

Follow https://ctan.org/tex-archive/macros/latex/contrib/fancyhdr/

  1. download fancyhdr and put it in the same direction as my project. --> NOT WORK

enter image description here

ERROR MESSANGE


"C:/Users/mreal/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS Bocong_Zhao_CV.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output Bocong_Zhao_CV.tex --lua-filter "C:\Users\mreal\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\mreal\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --template "C:\Users\mreal\Documents\R\win-library\4.0\vitae\rmarkdown\templates\awesomecv\resources\awesome-cv.tex" --highlight-style tango --pdf-engine xelatex --lua-filter "C:\Users\mreal\AppData\Local\Temp\RtmpWS10Cr/multiple-bibliographies.lua" 
output file: Bocong_Zhao_CV.knit.md

This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2021/W32TeX) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
tlmgr search --file --global "/fancyhdr.sty"
Trying to automatically install missing LaTeX packages...
tlmgr install fancyhdr

C:\Users\mreal\AppData\Roaming\TinyTeX\texmf-dist\scripts\texlive\tlmgr.pl: checksum error when downloading C:\Users\mreal\AppData\Local\Temp\5CDMmmAjHj\tofxssBK1c from https://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb: digest disagree
tlmgr update --self
tlmgr install fancyhdr

C:\Users\mreal\AppData\Roaming\TinyTeX\texmf-dist\scripts\texlive\tlmgr.pl: signature verification error of C:/Users/mreal/AppData/Roaming/TinyTeX/tlpkg/texlive.tlpdb.main.f5c4932332eb88bb88cf51695a8348dc from https://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb: cryptographic signature verification of
  C:\Users\mreal\AppData\Local\Temp\dR_FqlxNnR\GiyOF9OqTa
against
  https://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb.sha512.asc
failed. Output was:
gpg: Signature made Mon Jan 31 08:54:15 2022 CST using RSA key ID 19438C70
gpg: BAD signature from "TeX Live Distribution <[email protected]>"

Please try from a different mirror and/or wait a few minutes
and try again; usually this is because of transient updates.
If problems persist, feel free to report to [email protected].

This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2021/W32TeX) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
tlmgr search --file --global "/fancyhdr.sty"

C:\Users\mreal\AppData\Roaming\TinyTeX\texmf-dist\scripts\texlive\tlmgr.pl: signature verification error of C:/Users/mreal/AppData/Roaming/TinyTeX/tlpkg/texlive.tlpdb.main.f5c4932332eb88bb88cf51695a8348dc from https://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb: cryptographic signature verification of
  C:\Users\mreal\AppData\Local\Temp\DlM8ru8E2v\iVIYztqbrB
against
  https://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb.sha512.asc
failed. Output was:
gpg: Signature made Mon Jan 31 08:54:15 2022 CST using RSA key ID 19438C70
gpg: BAD signature from "TeX Live Distribution <[email protected]>"

Please try from a different mirror and/or wait a few minutes
and try again; usually this is because of transient updates.
If problems persist, feel free to report to [email protected].

! LaTeX Error: File `fancyhdr.sty' not found.

! Emergency stop.
<read *> 

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

Then I restart R and run again, the error shows another file is missing?

output file: Bocong_Zhao_CV.knit.md

"C:/Users/mreal/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS Bocong_Zhao_CV.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output Bocong_Zhao_CV.tex --lua-filter "C:\Users\mreal\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\mreal\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --template "C:\Users\mreal\Documents\R\win-library\4.0\vitae\rmarkdown\templates\awesomecv\resources\awesome-cv.tex" --highlight-style tango --pdf-engine xelatex --lua-filter "C:\Users\mreal\AppData\Local\Temp\RtmpI9GExN/multiple-bibliographies.lua" 
This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2021/W32TeX) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
tlmgr search --file --global "/fancyhdr.sty"
Trying to automatically install missing LaTeX packages...
tlmgr install fancyhdr

C:\Users\mreal\AppData\Roaming\TinyTeX\texmf-dist\scripts\texlive\tlmgr.pl: signature verification error of C:/Users/mreal/AppData/Roaming/TinyTeX/tlpkg/texlive.tlpdb.main.f5c4932332eb88bb88cf51695a8348dc from https://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb: cryptographic signature verification of
  C:\Users\mreal\AppData\Local\Temp\YsRRiAufp3\V9LgMoCzwu
against
  https://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb.sha512.asc
failed. Output was:
gpg: Signature made Wed Feb  2 08:58:50 2022 CST using RSA key ID 19438C70
gpg: BAD signature from "TeX Live Distribution <[email protected]>"

Please try from a different mirror and/or wait a few minutes
and try again; usually this is because of transient updates.
If problems persist, feel free to report to [email protected].

tlmgr update --self
tlmgr install fancyhdr
tlmgr.pl: package repository https://www.ctan.org/tex-archive/systems/texlive/tlnet (verified)
[1/1, ??:??/??:??] install: fancyhdr [5k]
running mktexlsr ...
done running mktexlsr.
tlmgr.pl: package log updated: C:/Users/mreal/AppData/Roaming/TinyTeX/texmf-var/web2c/tlmgr.log
tlmgr.pl: command log updated: C:/Users/mreal/AppData/Roaming/TinyTeX/texmf-var/web2c/tlmgr-commands.log
This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2021/W32TeX) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
tlmgr search --file --global "/xifthen.sty"

C:\Users\mreal\AppData\Roaming\TinyTeX\texmf-dist\scripts\texlive\tlmgr.pl: checksum error when downloading C:\Users\mreal\AppData\Local\Temp\il7JX9S6MK\VAwx4nKzS9 from https://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb: digest disagree
! LaTeX Error: File `xifthen.sty' not found.

! Emergency stop.
<read *> 

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


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source