quarto-dev / quarto-actions

GNU General Public License v2.0
228 stars 53 forks source link

Issue with Chinese Font Detection in Quarto GitHub Action for PDF Output #103

Closed TomBener closed 7 months ago

TomBener commented 7 months ago

Hello Quarto Team,

I've been experiencing a persistent issue when using the quarto-dev/quarto-actions to generate PDFs through GitHub Actions. Despite various troubleshooting efforts, I'm unable to resolve a font detection problem specifically related to the "Kaiti SC" font, which is not directly used or specified in my documents.

Description

When I utilize the Quarto GitHub Action to build my PDF using a LaTeX template that leverages the ctex package, the GitHub Action build process fails with an error indicating that the "Kaiti SC" font cannot be found. This error occurs even though my LaTeX template specifies FangSong for CJK fonts and does not reference "Kaiti SC" at all.

This issue is reproducible in a repository I've set up specifically for demonstrating this problem. The GitHub Action log can be viewed here. As you can see, after running for over 20 minutes, the GitHub action printed the following error messages:

Rendering PDF
running xelatex - 1
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

updating tlmgr

updating existing packages
finding package for ctex.sty
> 1 package to install
> installing ctex (1 of 1)
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

finding package for Kaiti SC(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)
ERROR: 
compilation failed- no matching packages
Package fontspec Error: The font "Kaiti SC" cannot be found.

For immediate help type H <return>.
 ...                                              

l.99   }

Additional Context

However, it is noted that the PDF can be built successfully on my machine with the same configurations:

Quarto check on my local Mac ``` ❯ quarto check Quarto 1.5.25 [✓] Checking versions of quarto binary dependencies... Pandoc version 3.1.11: OK Dart Sass version 1.70.0: OK Deno version 1.41.0: OK [✓] Checking versions of quarto dependencies......OK [✓] Checking Quarto installation......OK Version: 1.5.25 Path: /Applications/quarto/bin [✓] Checking tools....................OK TinyTeX: v2024.03.13 Chromium: (not installed) [✓] Checking LaTeX....................OK Using: TinyTex Path: /Users/tomben/Library/TinyTeX/bin/universal-darwin Version: 2024 [✓] Checking basic markdown render....OK [✓] Checking Python 3 installation....OK Version: 3.10.10 Path: /Users/tomben/.pyenv/versions/3.10.10/bin/python3 Jupyter: 5.5.0 Kernels: python3 [✓] Checking Jupyter engine render....OK [✓] Checking R installation...........OK Version: 4.3.3 Path: /opt/homebrew/Cellar/r/4.3.3/lib/R LibPaths: - /Users/tomben/.R/packages - /opt/homebrew/lib/R/4.3/site-library - /opt/homebrew/Cellar/r/4.3.3/lib/R/library knitr: 1.45 rmarkdown: 2.25 [✓] Checking Knitr engine render......OK ```

I have tried various troubleshooting steps, including specifying the font directories and confirming the font availability on my local system, which does not exhibit this issue.

I suspect there might be a bug in the Quarto GitHub action or perhaps an issue with the TinyTeX distribution used therein, specifically related to font handling or the ctex package.

Any assistance or insights you could provide would be greatly appreciated.

Thank you!

cderv commented 7 months ago
runs-on: macos-latest

Can you try running on ubuntu-latest and see if you have the issue ?

It is possible somehow that the font can't be installed on MacOS runner on github action. I can find some occurrence of this error in old issue related to MAC and Kaiti SC

where a specific configuration seems needed.

It could also just be that the font is not available (installed) on Gihtub MacOS runner - though it seems it should be available (https://chinesemac.org/pages/fonts.html#Apple)

So could be a detection issue.

Anyhow, I don't think this is related to Quarto. It seems the LaTeX can't find the font that works with the ctex package.

You should look for assistance in places with people who can help with Mac + ctex + fonts.

If you find that LaTeX works ok outside of Quarto rendering to PDF, then this could be a quarto issue somehow

TomBener commented 7 months ago

Thanks. The good news is runs-on: ubuntu-latest has passed successfully. But for some reason I have to use macos-latest. The weird issue is that the project can be built on my Mac with the same configurations. If keep-tex: true, compiling index.tex can succeed as well.

cscheid commented 7 months ago

This appears to be coming from some configuration difference between your local machine and the macOS github runner. I'm going to go ahead and close the issue.

TomBener commented 7 months ago

Thanks for your help. I finally figured out that this is indeed the cause of missing fonts. GitHub Action's macOS runner comes different from the standard version, the former removed all fonts under ~/Library/Fonts, so I consistently encountered the issue that The font "Kaiti SC" cannot be found. To fix the issue, I have added an extra step to install the necessary fonts before compiling the PDF, and now it works.

However, while the PDF can be generated, there is another issue when generating bibliography. The related log messages are as follows:

generating bibliography
  Can't load '/var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/auto/XML/LibXML/LibXML.bundle' for module XML::LibXML: dlopen(/var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/auto/XML/LibXML/LibXML.bundle, 0x0001): Symbol not found: _iconv
    Referenced from: <4FABCE36-0023-3D1B-A158-3499EFD82412> /private/var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/libxml2.2.dylib
    Expected in:     <E05EA2EB-4F11-36B6-87E5-41C89C1BCC5D> /private/var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/libiconv.2.dylib at /loader/HASH(0x134056520)/DynaLoader.pm line 210.
   at /loader/HASH(0x1340ce6b0)/PAR/Heavy.pm line 104.
  BEGIN failed--compilation aborted at /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/XML/LibXML.pm line 156.
  Compilation failed in require at /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/XML/LibXML/Simple.pm line 21.
  BEGIN failed--compilation aborted at /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/XML/LibXML/Simple.pm line 21.
  Compilation failed in require at /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/Biber/LaTeX/Recode.pm line 16.
  BEGIN failed--compilation aborted at /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/Biber/LaTeX/Recode.pm line 16.
  Compilation failed in require at /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/Biber/Utils.pm line 19.
  BEGIN failed--compilation aborted at /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/Biber/Utils.pm line 19.
  Compilation failed in require at /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/Biber/Internals.pm line 8.
  BEGIN failed--compilation aborted at /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/Biber/Internals.pm line 8.
  Compilation failed in require at /loader/HASH(0x1340a8e88)/parent.pm line 16.
  BEGIN failed--compilation aborted at /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/par-72756e6e6572/cache-351a9b4d1739a271ecf0be692d0ec1ef0a81d258/inc/lib/Biber.pm line 5.
  Compilation failed in require at script/biber-darwin line 17.
  BEGIN failed--compilation aborted at script/biber-darwin line 17.

running xelatex - 2
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

running xelatex - 3
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

running xelatex - 4
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

running xelatex - 5
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

running xelatex - 6
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

running xelatex - 7
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

running xelatex - 8
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

running xelatex - 9
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

running xelatex - 10
  This is XeTeX, Version 3.141592653-2.6-0.999996 (TeX Live 2024) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

WARN: maximum number of runs (9) reached

Output created: publish/index.pdf

In the generated index.pdf, citations were processed incorrectly. I have searched relevant issue such as this one, but it didn't help. Could you help to diagnose this issue? Thank you very much.

TomBener commented 7 months ago

UPDATED:

The issue above is the bug of biber as discussed in this issue. By using the latest version of biber, it works.

cderv commented 7 months ago

Thanks for the update @TomBener ! Glad it works now.

Could you help to diagnose this issue? Thank you very much.

We are happy to help when we can - just for next time, open new issue for new topic. Yes this is related, but the issue would have been different than the initial one. We would like each issue to be scoped to one topic. Thanks !