Add nil guards for kpse.find_file in unicode data loading - #338
Closed
WyattAu wants to merge 1 commit into
Closed
Conversation
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
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.
Summary
Adds nil guards for all
io.open(kpse.find_file(...))calls that load Unicode data files across 3 source files. Whenkpse.find_filereturns nil (e.g. when theunicode-datapackage is not installed, or the font cache is empty/corrupted), the current code crashes with a cryptic error:This PR replaces those crashes with a clear error message:
Fixes
kpse.find_filereturns nil forScriptExtensions.txtduring early initkpse.find_filepicks up wrongUnicodeData.txtfrom CWD (the nil guard prevents the crash; the root cause is in kpse behavior)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 --updatecompletes successfully (font cache rebuilds)