欢迎来到 Moita's Programming Blog¶
RStudio 调用 MiKTeX 问题
控制台报错
command line: E:\LaTeX\MiKTeX\miktex\bin\x64\pdflatex.exe -halt-on-error -interaction=batchmode ***.tex
2026-xx-xx xx:xx:xx,580+1300 INFO pdflatex - running on Windows 10.0.19045
2026-xx-xx xx:xx:xx,594+1300 WARN pdflatex - security risk: running with elevated privileges
2026-xx-xx xx:xx:xx,597+1300 INFO pdflatex - this is MiKTeX-PDFTEX 4.26.0 (1.40.29) (MiKTeX 26.2)
2026-xx-xx xx:xx:xx,601+1300 INFO pdflatex - allowing known shell commands
2026-xx-xx xx:xx:xx,872+1300 FATAL pdflatex.core - GUI framework cannot be initialized.
2026-xx-xx xx:xx:xx,872+1300 FATAL pdflatex.core - Data:
2026-xx-xx xx:xx:xx,872+1300 FATAL pdflatex.core - Source: Libraries\MiKTeX\UI\Qt\mikuiqt.cpp:126
2026-xx-xx xx:xx:xx,872+1300 FATAL pdflatex - GUI framework cannot be initialized.
2026-xx-xx xx:xx:xx,873+1300 FATAL pdflatex - Info:
2026-xx-xx xx:xx:xx,873+1300 FATAL pdflatex - Source: Libraries\MiKTeX\UI\Qt\mikuiqt.cpp
2026-xx-xx xx:xx:xx,873+1300 FATAL pdflatex - Line: 126
2026-xx-xx xx:xx:xx,873+1300 INFO pdflatex - this process (4200) finishes with exit code 1
2026-xx-xx xx:xx:xx,874+1300 ERROR pdflatex - major issue: So far, you have not checked for MiKTeX updates.
2026-xx-xx xx:xx:xx,874+1300 WARN pdflatex.core - still open: ***.tex
2026-xx-xx xx:xx:xx,874+1300 WARN pdflatex.core - still open: ***.log
为什么会这样?RStudio + MikTex 遇到了以上的报错
Hugging Face 缓存目录设置
要让 Hugging Face(包括 sentence-transformers)模型的缓存目录永久改到非 C 盘(例如 D:\HF_cache 或 E:\huggingface_hub),最推荐、最干净的方式是设置系统级或用户级的环境变量 HF_HOME。这样所有 Hugging Face 相关的库(transformers、sentence-transformers、huggingface_hub、datasets 等)都会自动使用新路径,无需每次在代码里写 cache_dir=...。