Skip to content

Conversation

@Witiko
Copy link

@Witiko Witiko commented Feb 13, 2023

Closes #3. Compared to the workaround given in #3, this solution is automatic for the user and does not require setting a kpse global.

@zauguin
Copy link
Member

zauguin commented Feb 18, 2023

First of all we can't call kpse.set_program_name unconditionally without breaking kpse for other usecases since it resets the program name.

Beside that it feels like working around a conscious decision of ConTeXt. IMO doing something like local kpse = kpse or require'kpse' would make sense since this could deal with the case that kpse isn't loaded, but here the existing kpse library is explicitly hidden and overwritten with a stub. That ConTeXt decided not just not to use kpathsea but to actively hide it indicates to me that it shouldn't be used in that context. Does anyone know if the library still being available though require is an intended feature of ConTeXt or if it was just forgotten to disable it there?

@zauguin zauguin self-requested a review February 18, 2023 16:53
kpse.set_program_name'kpsewhich'
end
local kpse = require'kpse'
kpse.set_program_name'kpsewhich'
Copy link
Member

Choose a reason for hiding this comment

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

This breaks name lookup when used in LaTeX.

Copy link
Author

Choose a reason for hiding this comment

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

How so?

Copy link
Member

Choose a reason for hiding this comment

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

It changes the current progname in kpathsea to kpsewhich from this point on, therefore all engine specific overwrites in texmf.cnf are disabled and expansions of $progname in lookup paths lead to the wrong result.
So if you for example have a tex file with the same name in texmf/tex/luatex and texmf/tex/generic, then the luatex version is preferred before and the generic one afterwards.

This doesn't matter too much with TeX Live's default setup since that always falls back to the other directories if a file isn't found and TeX Live generally doesn't reuse filenames, but it can easily break user settings.

@Witiko
Copy link
Author

Witiko commented Feb 18, 2023

Here is my understanding: ConTeXt is commonly distributed as a part of the ConTeXt Standalone distribution, which does not contain either kpathsea or other parts of TeX Live. If you need kpsewhich in TeX Live, you can explicitly require it but it is unnecessary for the working of ConTeXt.

@Witiko
Copy link
Author

Witiko commented Feb 19, 2023

However, I tend to agree that the responsibility for loading kpathsea in ConTeXt should perhaps fall on the shoulders of users, seeing how it affects the global state. Therefore, you may want to close both this pull request and #3 as a wontfix.

local codes = utf8.codes
local unpack = table.unpack

if tex.initialize then
Copy link
Author

Choose a reason for hiding this comment

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

@zauguin Out of curiosity, where is tex.initialize defined? I don't see any mention in either luatex.pdf or ltluatex.pdf.

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.

Always explicitly load the kpse module

2 participants