Skip to content

Add nil guards for kpse.find_file in unicode data loading - #338

Closed
WyattAu wants to merge 1 commit into
latex3:mainfrom
WyattAu:fix/kpse-nil-guard
Closed

Add nil guards for kpse.find_file in unicode data loading#338
WyattAu wants to merge 1 commit into
latex3:mainfrom
WyattAu:fix/kpse-nil-guard

Conversation

@WyattAu

@WyattAu WyattAu commented Aug 31, 2026

Copy link
Copy Markdown

Summary

Adds nil guards for all io.open(kpse.find_file(...)) calls that load Unicode data files across 3 source files. When kpse.find_file returns nil (e.g. when the unicode-data package is not installed, or the font cache is empty/corrupted), the current code crashes with a cryptic error:

bad argument #1 to 'open' (string expected, got nil)

This PR replaces those crashes with a clear error message:

luaotfload: Cannot find ScriptExtensions.txt. Install the 'unicode-data' TeX package (tlmgr install unicode-data).

Fixes

Files changed

  • src/luaotfload-multiscript.lua — 2 occurrences (ScriptExtensions.txt, Scripts.txt)
  • src/luaotfload-unicode.lua — 5 occurrences (UnicodeData.txt ×2, PropList.txt, WordBreakProperty.txt, SpecialCasing.txt)
  • src/luaotfload-notdef.lua — 2 occurrences (UnicodeData.txt, PropList.txt)

Testing

Verified locally on Arch Linux (TeX Live 2026) where the bug was reproduced by deleting the font cache. After applying this patch:

  • luaotfload-tool --update completes successfully (font cache rebuilds)
  • Documents using luaotfload compile normally
  • If the files truly can't be found, users get a clear actionable error message instead of a crash

io.open(kpse.find_file"...") crashes with a cryptic error when
kpse.find_file returns nil (e.g. when the unicode-data package is
not installed, or when the font cache is empty/corrupted).

Add nil guards with a clear error message directing users to install
the 'unicode-data' TeX package.

Fixes latex3#264
Closes latex3#335
@zauguin zauguin closed this Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

luaotfload-unicode.lua fails when near UnicodeData.txt Failed to load "luaotfload" module "multiscript"

2 participants