GitHub Action中kpsewhich报错:无法找到TeX Live根目录
解决GitHub Action中TeX Live TLMGR更新脚本报错问题
问题根源
你遇到的错误是因为通过apt安装的TeX Live是Ubuntu打包后的版本,和官方TLMGR更新脚本不兼容——脚本无法识别apt安装的TeX Live根目录结构,导致找不到必要的配置文件。
解决方案
方案1:使用现成LaTeX Action(推荐)
直接使用社区维护的xu-cheng/latex-action,它会自动配置完整的TeX Live环境,包含所有必要工具和包管理功能,无需手动处理依赖冲突:
替换原工作流中Install latexmk, zip, and cmap...的步骤为:
- name: Set up LaTeX environment uses: xu-cheng/latex-action@v2 with: scheme: full # 安装完整TeX Live包集合 extra_packages: cmap # 额外安装需要的cmap包
方案2:修复apt安装后的路径问题(不推荐)
如果坚持使用apt安装的TeX Live,需要调整PATH并跳过官方更新脚本(apt版本的TLMGR不需要通过该脚本更新):
修改原安装步骤为:
sudo apt-get update sudo apt-get upgrade -y # 安装包含cmap的完整TeX Live包 sudo apt-get install -y latexmk zip texlive-full texlive-fonts-extra # 将TeX Live的bin目录加入PATH export PATH=/usr/local/texlive/2023/bin/x86_64-linux:$PATH # 直接用apt自带的tlmgr安装cmap tlmgr install cmap
修改后的完整工作流示例
name: Generate and Deploy Documentation on: push: branches: - main # Replace with your branch name jobs: build-deploy: runs-on: ubuntu-latest steps: - name: Checkout source code uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.9' # 使用方案1的LaTeX Action替换原安装步骤 - name: Set up LaTeX environment uses: xu-cheng/latex-action@v2 with: scheme: full extra_packages: cmap - name: Install dependencies run: | pip install sphinx sphinx_rtd_theme - name: Generate HTML documentation run: | cd docs make html make latexpdf mv ./build/latex/amadla.pdf ./amadla.pdf rm -rf ./build/latex/* mv ./amadla.pdf ./latex/amadla.pdf make epub zip -r amadla.epub ./build/epub/* rm -rf ./build/epub/* mv ./amadla.epub ./epub/amadla.epub - name: Checkout AmadlaOrg.github.io repository uses: actions/checkout@v3 with: repository: AmadlaOrg/AmadlaOrg.github.io token: ${{ secrets.GH_PAT_DOC }} path: ./AmadlaOrg.github.io - name: Copy HTML documentation to AmadlaOrg.github.io repository run: | cp -r docs/build/* ./AmadlaOrg.github.io/docs - name: Commit and push changes run: | cd ./AmadlaOrg.github.io git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add . if [ -n "$(git status --porcelain)" ]; then git commit -m "Update documentation" git push fi
内容的提问来源于stack exchange,提问作者jnbdz
相关产品推荐
相关产品推荐

