Repository navigation
fix(diagnostics): report pdfTeX and fatal engine errors - #68
Merged
Merged
Conversation
Recognize pdfTeX's own fatal errors (`!pdfTeX error: ...`, e.g. a font or an image it cannot load) and give every failed compile an error diagnostic, excerpting the end of the log when no error was recognized. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
nishide-dev
force-pushed
the
fix/pdftex-errors
branch
from
October 6, 2026 22:31
7c4865e to
d735662
Compare
nishide-dev
commented
Oct 6, 2026
nishide-dev
left a comment
Owner
Author
There was a problem hiding this comment.
Verdict: APPROVE
must-fix / should-fix はありません。#66 の再現(T1 + MKTEXPK=0 の font 不足)がこの PR で 1 error(位置なし other)+ info の stop になること、unexplained_failure が付く条件が outcome: failed かつ error 0 件だけに絞られていて正常終了・timeout・cancel・resource limit では付かないことを、コードと実際の compile の両方で確認しました。#23 の方針(誤った file/line より None)、#40 の方針(stop は error の後なら info)、#42 の方針(計算量・読み込み量に上限)にも沿っています。
ゲート
- host (macOS):
cargo fmt --check/cargo clippy -D warnings/cargo test --workspace --all-features --lockedすべて通過 - dev コンテナ:
TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --locked全件通過(skill_docsも含む) - CI はすべて pass
試したケース(dev コンテナ、scratchpad 内、コミットなし)
texrun compile --json での結果:
| ケース | 結果 |
|---|---|
T1 fontenc(ecrm1000) |
error other "pdfTeX error: pdflatex (file ecrm1000): Font ecrm1000 at 600 not found"(file/line なし)+ info stop |
\pdfximage{nosuch.png} |
error other "pdfTeX error: pdflatex: cannot find image file nosuch.png" + info |
壊れた PNG を \includegraphics |
error other "pdfTeX error: pdflatex (file ./bad.png): libpng: internal error" + info(fixture にない形式も拾えている) |
壊れた PDF を \includegraphics |
error other "pdfTeX error: pdflatex (file ./bad.pdf): xpdf: reading PDF image failed" + info |
| 未定義命令の後に T1 font / 存在しない画像 | -halt-on-error で先に止まり pdfTeX error は log に出ない。error 1 件 + info、unexplained は付かない |
| LaTeX Error(itemize/enumerate 不一致) | latex_error 1 件 + info |
\end{document} なし(! Emergency stop. だけ) |
error emergency_stop 1 件(従来どおり)、unexplained は付かない |
| 正常終了 / warning のみ | succeeded、余計な error なし |
parser / unexplained_failure に直接入れた log(実ログの切り詰めと合成):
! LaTeX Error→==> Fatal error→!pdfTeX error:(no-halt で最終 ship 時に font が落ちる想定): LaTeX error、info stop、pdfTeX error の 2 error。どちらも直すべき別の問題なので件数として正しい。- 未定義命令 →
!pdfTeX error:→==> Fatal: 2 error + info 1 件。二重報告なし。 !pdfTeX error:の後に! Emergency stop.: 後者は info(errors_reportedが数えられている)。Runaway argument?の直後の!pdfTeX error:、CRLF の log: どちらも正しく拾える。- log が途中で切れたもの:
!pdfTeX error行の途中で切れると message も途中まで("pdfTeX error: pdfla")。summary の前で切れると error だけ。!の前で切れると unexplained になり、末尾 12 行が excerpt に入る。いずれも妥当。 - LuaLaTeX で
\directlua{os.exit(3)}(log が途中で終わる): unexplained になり、excerpt は末尾の Font Info 12 行。 - 計算量: 1 / 64 / 512 MiB の log(80 byte ごとに改行、または改行のない 1 行の
!...)でunexplained_failureは 14〜104 µs、message は 2048 B 以下、excerpt は 4096 B 以下。log サイズに依らないことを確認。ESC と不正 UTF-8 は sanitize される(unit test もあり)。 - この container には XeLaTeX が無いので XeTeX の log は試せていません。LuaTeX の
./x.tex:3: error: (file nosuch.png) (pdf backend): ...は従来どおりfile:line:形式で拾えます。
nit
- human 出力で excerpt が見えない:
the compile failed, but no error was recognized in the log; its last lines are in the excerpt (see the full log)は、raw_excerptを表示しない human 出力(human.rs)では見えないものを指しています(その下にlog:のパスは出ます)。どちらかで良いと思います。- message を出力形式に依らない文にする。例:
the compile failed, but no error was recognized in the log; read the end of the log - human 出力でこの error に限って
raw_excerptを数行表示する
- message を出力形式に依らない文にする。例:
- docs/cli.md の「the last
!line of the log」: 実際に見るのは最後の 16 KiB のうち非空行 12 行だけです。log の前の方の!行は引用されません。quotes the last line starting with!among the last lines of the logのように書くと正確です。 - 原因不明の
!行の後に認識できる stop が続く場合: 合成 log!XeTeX error: odd→! ==> Fatal error occurred, ...では、stop が error(emergency_stop, "Fatal error occurred...")になります。error が 1 件あるので unexplained は付かず、本当の原因の行はどこにも出ません。texrun の engine は今は pdflatex だけで、pdfTeX 自身の形式はこの PR で拾えるので、今は実害はないと思います。XeTeX / LuaTeX を入れるときの follow-up として、「先に error がない stop しか error がない」場合にも unexplained の excerpt(または stop の excerpt に前の数行)を付けることを検討してください。! Emergency stop.だけのケース(\end{document}なし)で*** (job aborted, no legal \end found)が excerpt に入らないのも同じ種類の既存の弱さです。 - errors.md の対処の具体化:
Font ecrm1000 at 600 not foundには「\usepackage{lmodern}を足す(T1 のまま Type 1 の font にする)か、fontencの T1 をやめる」と具体的な直し方があると、agent がそのまま直せます。I can't write on fileはopenout_any=pなので、絶対パスや..の他に、.で始まる(hidden)ファイルへの書き込みでも出ます。「writing outside the project or to a hidden file」とする方が正確です。
MainLog::newが成功時もunexplained_failureを毎回計算している: 16 KiB の lossy 変換と 12 行の処理だけなので実害はありません。気になるなら、parse_logが log の末尾(最大 16 KiB)だけを持って返し、必要なときだけ計算する形にもできます。- テストの網羅: engine 側のテストは
Failedの場合だけです。decideの構造上 timeout / cancel / resource limit では付きませんが、「TimedOutで error 0 件のとき unexplained を足さない」ことを固定するテストが 1 本あると、将来条件を変えたときの回帰を防げます(fake latexmk のsleep+ 短い timeout で書けます)。
Word the message so it holds without the excerpt (the human output does not show it), describe what is quoted precisely, make the skill's fixes for missing fonts and refused writes concrete, and check that a timeout gets no extra error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 tasks done
nishide-dev
added a commit
that referenced
this pull request
Oct 6, 2026
… image (#67) ## 概要 公開済みの engine image 0.1.0 と dev image では、普通の `itemize` を含む文書が `!pdfTeX error: pdflatex (file tcrm1000): Font tcrm1000 at 600 not found` で失敗していた。両 image に Type1 font(`cm-super`・`lmodern`・`texlive-fonts-recommended`)を追加して直す。`MKTEXPK=0`(docs/security.md §3.4)の方針は変えていない。 ## 原因 - LaTeX 2024-11-01(trixie の TeX Live 2024)では、OT1 文書の `\textbullet` が `\UseTextSymbol{TS1}` になっている(`\?\textbullet` の定義で確認)。そのため `\labelitemi` を使う `itemize` は TS1 の `tcrm1000` を必要とする。`\usepackage[T1]{fontenc}` の文書も EC の `ecrm1000` を必要とする - image には `texlive-latex-base` の TFM(`fonts/tfm/jknappen/ec/tcrm1000.tfm`)だけが入っていて、Type1(`.pfb` と map)は入っていなかった - texrun は `MKTEXPK=0` で bitmap(PK)を生成させないので、pdfTeX は font を埋め込めずに失敗する。PK を生成させずに Type1 を入れるのが正しい対処 - 再現の結果(修正前) | 文書 | engine 0.1.0 | dev image(host backend 相当) | | --- | --- | --- | | `itemize` だけ | `tcrm1000` not found | 同じ | | textcomp 記号 + amsmath/amssymb/graphicx/booktabs/geometry/microtype/hyperref | `tcrm1000` not found | 同じ | | `\usepackage[T1]{fontenc}` + microtype | `ecrm1000` not found | 同じ | | T1 + `lmodern` + 上記 | `lmodern.sty` not found | 同じ | | `mathptmx` / `helvet` / `mathpazo` | `ptmr8t` / `pplr7t` の TFM が無い | 同じ | - 既存の fixture が通っていた理由: どれも OT1 の本文だけで、`itemize`・textcomp 記号・T1 を使っていなかった。OT1 の Computer Modern の Type1 は `texlive-base`(amsfonts)に入っている ## 変更内容 - `docker/engine/Dockerfile` と `docker/dev/Dockerfile`: `texlive-fonts-recommended`・`cm-super`・`lmodern` を追加した(`--no-install-recommends` のまま)。理由はコメントに書いた - `crates/texrun-texlive/tests/fixtures/common-packages/`: 4 つの文書を追加した - `main.tex`: 11pt、OT1。入れ子の itemize、enumerate、textcomp 記号(脚注や `\small` / `\Huge` の中でも使う)、amsmath/amssymb、graphicx(PNG)、booktabs、geometry、microtype、hyperref - `t1.tex`: 12pt、T1。lmodern なしで cm-super をいろいろなサイズで使う - `lmodern.tex`: T1 + lmodern + 上記のパッケージ - `psnfss.tex`: mathptmx / helvet / courier - `palatino.tex`: mathpazo(sc,osf) - `main.tex` には description(中に itemize)も入れている - `scenarios.rs` に `common_packages` を追加した。5 文書が成功し、error と未解決の参照が無く、1 ページの PDF ができることを確認する。`scenarios.rs` は CI の `integration` job(dev image で latexmk を host backend として実行)と `sandbox` job(`TEXRUN_TEST_BACKEND=container`)の両方で走るので、両 backend を検証できる。engine-image workflow の `verify` でも走る - #68(`!pdfTeX error:` の parser 対応)との整合 - #68 の log fixture `pdftex-missing-font` は、cm-super が無いことを前提にした `ecrm1000` で失敗させていた。この PR で dev image に cm-super が入るので、Type1 の無い `cmntt10`(cmextra)を使う文書に変えた。log を再生成し、`real_logs.rs` の期待値と `regenerate.sh` のコメントを更新した。ほかの log は timestamp しか変わらないので戻している - `skills/texrun/reference/errors.md` と docs/cli.md の font 不足の例を `cmntt10` に変えた。errors.md は、Type1 のある font(既定の CM、T1、lmodern、mathptmx / helvet / mathpazo)に切り替えるよう案内する。itemize や T1 でも失敗するなら engine image 0.1.0 なので、新しい image を使うよう書いた - docs: engine-image.md のライセンス表に font と依存パッケージを追加し(`cm-super` / `cm-super-minimal`、URW の Type1 は GPL + font exception)、PDF への font 埋め込みについて追記した。development.md(dev image の内容と version)と security.md(§3.4・§4 の image 構成)も更新した ### パッケージの選定 | 候補 | image layer | sources tar への追加 | 結果 | | --- | --- | --- | --- | | `cm-super-minimal` | +6.8 MB | cm-super source(約 65 MiB) | 10pt の font しか入っていない。`itemize` の 10pt 文書は通るが、11pt 文書・見出し(`sfbx1440`)・脚注(`tcrm0800`)で失敗するので不採用 | | **`cm-super`** | +63 MB | cm-super source(約 65 MiB)+ `pfb2t1c2pfb` | T1 / TS1 の全サイズ。LaTeX の既定の font で必要になるので採用 | | **`lmodern`** | +39 MB | ほぼ 0(source package `lmodern` は既存の `fonts-lmodern` と同じ。`xfonts-utils` などが約 2 MiB) | `\usepackage{lmodern}` は T1 文書の定番なので採用。font 本体の `fonts-lmodern` はもともと `texlive-latex-base` の依存で入っていて、LaTeX 用のファイル(sty/fd/tfm)だけが無かった | | **`texlive-fonts-recommended`** | +19 MB | 0(source package `texlive-base` は既存) | PSNFSS(Times・Helvetica・Courier・Palatino など)。論文でよく使われ、source は増えないので採用 | | `tex-gyre` など | — | — | 追加しない(必要になったら別 Issue で) | - ライセンス: `cm-super` は GPL-2.0-or-later(font exception 付き)、Latin Modern は GUST Font License(LPPL の変種)。依存の `pfb2t1c2pfb` は GPL、`xfonts-utils` / `xfonts-encodings` / `libfontenc` は MIT / X11。いずれも PDF への font 埋め込みは許されている - 新しく入る source package は `cm-super`、`pfb2t1c2pfb`、`xfonts-utils`、`xfonts-encodings`、`libfontenc` の 5 つ(`dpkg-query` の差分で確認) ### サイズ | | 修正前(main) | 修正後 | | --- | --- | --- | | engine image(ローカル build、arm64、圧縮 / 展開後) | 171.4 MB / 657 MB | 250.9 MB / 856 MB | | dev image(圧縮 / 展開後) | 431.3 MB / 1.67 GB | 510.8 MB / 1.87 GB | | sources tar | 1,230,028,800 B(v0.1.0 の asset) | 1,299,312,640 B(この PR の engine-image workflow の sources job、148 source packages)。+69.3 MB(+66 MiB)で、上限 2 GiB に対する余裕は 848,170,368 B(約 809 MiB) | ## 確認方法 - [x] `cargo check --workspace --all-targets --all-features --locked` - [x] `cargo fmt --all -- --check` - [x] `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` - [x] `cargo test --workspace --all-features --locked`(host) - [x] dev image(この PR の Dockerfile で build)で `TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --locked`: 全部成功 - [x] ローカル build の engine image で、CI の sandbox job と同じ container テスト一式(`TEXRUN_TEST_BACKEND=container TEXRUN_REQUIRE_SANDBOX=1 TEXRUN_REQUIRE_TEXLIVE=1`): 全部成功、ignored 0 - [x] 修正前の image(main の engine image、既存の dev image)では `common_packages` が `Font tcrm0900 at 600 not found` で失敗することを確認した - [x] 生成された PDF の font は、`pdffonts` で見るとすべて Type 1 だった(bitmap は無い) - workflow は変えていないので actionlint は対象外。engine-image workflow の dry run(verify / build / sources)はこの PR で走る ## 関連 Issue Closes #65 修正版 image の公開(v0.1.1 の tag push と release)は、merge 後に owner の判断で行う。この PR では公開しない。 ## 補足 - 修正前は、この font error が diagnostics に error として出ていなかった(`!pdfTeX error:` の行が parser で拾われない)。parser 側は #66 で扱っているので、この PR では触っていない - image は約 +80 MB(圧縮)大きくなる。cm-super が大部分を占めるが、LaTeX の既定の font(T1 / TS1)なので削れない 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
nishide-dev
added a commit
that referenced
this pull request
Oct 6, 2026
## 概要 v0.1.1 を公開するため、版を 0.1.1 に上げます。 ## 変更内容 - `Cargo.toml` の workspace と内部 crate の版を 0.1.1 に(`Cargo.lock` も更新) - README、docs/engine-image.md、skills/texrun/reference/setup.md の版表記を 0.1.1 に(docs/development.md のリリース手順の版表記も) v0.1.1 に含まれる主な変更: - engine image / dev image に Type1 font(cm-super、lmodern、texlive-fonts-recommended)を追加し、itemize や T1 を使う一般的な文書が compile できるように(#65、PR #67) - `!pdfTeX error:` を error diagnostic として報告し、失敗した compile には必ず error を返す(#66、PR #68) - Agent Skill と Claude Code の plugin marketplace(#63、PR #64) ## 確認方法 - [x] `cargo test --workspace --all-features --locked` - [x] `git grep -n '0\.1\.0' -- README.md docs/ skills/` で残りは履歴・説明上の記述のみ(release notes の初版の例、engine image 0.1.0 の不具合の説明) ## 補足 merge 後に main へ `v0.1.1` の tag を push し、engine image と release(notes 付き)を自動公開します。texrun 0.1.0 は既定で engine image 0.1.0 を使うため、font の修正を得るには texrun を 0.1.1 に上げる必要があります(release notes に追記予定)。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
pdfTeX が自分で出す致命的エラー(
!pdfTeX error: ...。font や画像を読めないときなど)を log parser が拾わず、outcome: failedなのにdiagnostics: []になっていた問題を直す。あわせて、失敗した compile には必ず error diagnostic が 1 件以上付くようにする。変更内容
texrun-latex-log!pdfTeX error: ...(!の後に空白がなく、-file-line-errorでもfile:line:にならず、l.<n>もない)を error /otherとして報告する。直後の空白始まりの==> Fatal error occurred, ...は、TeX エラー後の stop と同じくemergency_stopのinfoとして扱う(feat(diagnostics): locate missing packages and fold fatal errors #40 の方針どおり、error の数が直すべき問題の数)file/lineは常にNone(file stack の推測もしない。message に font 名や画像名が入る)unexplained_failure(log)を公開:失敗したのに error が見つからないとき用に、log 末尾(最後の 16 KiB のうち非空行を最大 12 行)をraw_excerptに持つ error /otherを返す。末尾に!行があればそれを message に引用する。計算量は log サイズに依らず定数、message / excerpt は既存と同じ上限と sanitize を通すtexrun-texlive:outcome: failedで error diagnostic が 0 件のとき(log・texrun・BibTeX のどれも error を出さなかったとき)だけ、上記の error を追加する。log の読み込みは既存の 1 回分を使い回すotherにした。! pdfTeX error (ext4): ...のように TeX のエラールーチン経由の pdfTeX エラーは従来からotherで、同じ pdfTeX 由来のエラーで kind が分かれるのを避けるため。新設は必要になったら後から足せる(未知の kind はotherとして deserialize される)regenerate.shに追加)pdftex-missing-font:T1 のecrm1000(MKTEXPK=0、TeX Live engine と同じ設定)→!pdfTeX error: pdflatex (file ecrm1000): Font ecrm1000 at 600 not found(Report pdfTeX errors that the log parser misses #66 の再現)pdftex-missing-image:\pdfximage{nosuch.png}→!pdfTeX error: pdflatex: cannot find image file nosuch.pngpdftex-error-ext:\pdfendlinkだけ →./main.tex:5: pdfTeX error (ext4): ...(従来どおり位置付きのother)capacity-exceeded(TeX capacity exceeded)、cannot-write(openout_any=pでI can't write on file)、interruption(SIGINT でInterruption.):いずれも既にfile:line:形式の TeX エラーとして拾えていたことを固定する回帰テストskills/texrun/SKILL.md、reference/errors.md)を更新確認方法
cargo check --workspace --all-targets --all-features --lockedcargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test --workspace --all-features --locked(macOS host)TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --lockedtexrun compileして確認:T1 font の文書はerror: pdfTeX error: pdflatex (file ecrm1000): Font ecrm1000 at 600 not found(1 error)、\pdfximageの文書はerror: pdfTeX error: pdflatex: cannot find image file nosuch.pngreal_logs.rs)、pdfTeX エラーが後続の偽l.<n>や file stack から位置を取らないこと(synthetic.rs)、unexplained_failureの上限・sanitize・!行の引用(unit)、fake latexmk で「認識できるエラーなら追加しない / 未知形式・log なしなら追加する」(engine.rs)関連 Issue
Closes #66
補足
SKILL.mdの「failedなのに error がなければ log を読む」という暫定案内を、位置なしのothererror(pdfTeX の font / 画像エラー、または log 末尾の抜粋付きの原因不明エラー)の読み方に置き換え、reference/errors.mdのother行に対処を追記。kind は追加していないのでskill_docsの整合性テストはそのまま通る。scripts/texrun_summary.pyの「error が無い」分岐は古い texrun 向けに残したunexplained_failureは latexmk 自体の失敗(TeX は成功したが latexmk が非 0 で終了など)でも出るが、latexmk の stdout は JSON に出していないので、その場合は TeX log の末尾しか示せない!直後に空白がない独自形式は未対応だが、その場合もunexplained_failureがその!行を message に引用する🤖 Generated with Claude Code