Skip to content

Conversation

@brprice
Copy link

@brprice brprice commented Nov 8, 2025

kpathsea has some perhaps-surprising rules around "safe filenames". We attempt to make this information more discoverable by linking from the error message.

I have spent a bunch of time debugging why upgrading texlive-2023 to texlive-2025 meant I couldn't build my document via nix. The error message was rather unhelpful (yes there is a writeable cache directory, it is right there) as I was unaware of the "no hidden directories" rule. Hopefully this patch will save some time for the next person to trip across this (i.e. me in a few months time!)

Probably there is better phrasing of the additions to the message.

kpathsea has some perhaps-surprising rules around "safe filenames". We
attempt to make this information more discoverable by linking from the
error message.

if not writable then
logs.report("system","no writeable cache path, quiting")
logs.report("system","no writeable cache path, quiting. Try setting TEXMFCACHE or TEXMFVAR and reading https://www.tug.org/texinfohtml/kpathsea.html#Safe-filenames")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not a luaotfload developer, so feel free to ignore any of my comments here)

I don't think that logs.report wraps its output (assuming that it behaves like the version from ConTeXt), so it might be better to add the hint to a separate line:

Suggested change
logs.report("system","no writeable cache path, quiting. Try setting TEXMFCACHE or TEXMFVAR and reading https://www.tug.org/texinfohtml/kpathsea.html#Safe-filenames")
logs.report("system","no writeable cache path, quiting")
logs.report("system","Try setting TEXMFCACHE or TEXMFVAR and reading https://www.tug.org/texinfohtml/kpathsea.html#Safe-filenames")

In general though, adding a hint to this error message seems like a really good idea to me.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to be able to do this, but because of

do
local saved_reporter = texio.reporter
local saved_exit = os.exit
local errmsg
function texio.reporter(msg, ...)
errmsg = msg
end
function os.exit()
error(errmsg)
end
load_fontloader_module "basics-gen"
texio.reporter = saved_reporter
os.exit = saved_exit
end
only the last log is reported.

(I'm not a lua dev, so could easily be missing something here)

Trying to embed a newline in the string also makes the reporting a bit odd wrt indentation.

luaotfload | load : FATAL ERROR
luaotfload | load :   × Failed to load "fontloader" module "basics-gen".
luaotfload | load :   × Error message:
luaotfload | load :     × "./luaotfload-init.lua:301: system : no writeable cache path, quiting.\
Try setting TEXMFCACHE or TEXMFVAR and reading https://www.tug.org/texinfohtml/kpathsea.html#Safe-filenames".

...

./luaotfload-init.lua:301: system : no writeable cach
e path, quiting.
Try setting TEXMFCACHE or TEXMFVAR and reading https://www.tug.org/texinfohtml/
kpathsea.html#Safe-filenames

whereas just one long string gives

luaotfload | load : FATAL ERROR
luaotfload | load :   × Failed to load "fontloader" module "basics-gen".
luaotfload | load :   × Error message:
luaotfload | load :     × "./luaotfload-init.lua:301: system : no writeable cache path, quiting. Try setting TEXMFCACHE or TEXMFVAR and reading https://www.tug.org/texinfohtml/kpathsea.html#Safe-filenames".

...

./luaotfload-init.lua:301: system : no writeable cach
e path, quiting. Try setting TEXMFCACHE or TEXMFVAR and reading https://www.tug
.org/texinfohtml/kpathsea.html#Safe-filenames

I'm not particularly happy with either option here. Hopefully a maintainer can suggest a non-invasive change with nicer output.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either option is fine really. Currently the output looks weird but that shouldn't be worked around here but fixed in the output printer.

I think doing multiple calls to texio.reporter is the cleanest option for now.

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.

3 participants