Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make digestif working with ConTeXt standalone installation #68

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

evgeniysharapov
Copy link

I have a ConTeXt standalone installation. The caveat is it relies on LuaMetaTex and Lua scripts instead of prograps that come with TeX Live installation, s.a. kpsewhich and texlua. To make digestif work for me I had to alter the code a little bit.

Comment on lines -394 to +395
local ok = os.execute(format(is_command_cmd, name))
return ok and name or nil
local ok, err = pcall(os.execute, format(is_command_cmd, name))
return err == 0 and ok and name or nil
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this change needed? There is a difference between is_command_cmd exiting with non-zero status (which happens if a command named name doesn't exist) and the os.execute call failing, which presumably never happens.

Are you on Windows by any chance?

Copy link
Author

Choose a reason for hiding this comment

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

No, this one was got my Macbook. I wasn't able to run digestiff and went on debugging why it happened. ok was truthy even if command in this case texlua was not available. Using pcall and checking for error code seem to solve it. I admit that I am not a Lua programmer.

Comment on lines +10 to +13
local fullpath = debug.getinfo(1,"S").source:sub(2)
if arg[1] == fullpath then
table.remove(arg, 1)
end
Copy link
Owner

Choose a reason for hiding this comment

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

Funny, I can't observe the issue you describe here. I've tried texlua, luatex --luaonly and mtxrun --execute, and fullpath is always given as arg[0].

What is arg[0] in your situation? (And which platform?)

Copy link
Author

Choose a reason for hiding this comment

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

This is probably unique to standalone ConTeXt which I have installed on my Macbook. It does not have texlua and the suggestion was to use Lua engine from LuaMetatex which is accessible through the Lua script texlua.lua. This is how my ConTeXt bin directory looks like

lrwxr-xr-x  1 evgeniysharapov  staff    10B Jul  3 00:21 context -> luametatex
-rw-r--r--  1 evgeniysharapov  staff   1.3K Jul  3 00:21 context.lua
-rwxr-xr-x  1 evgeniysharapov  staff   3.0M Jul  3 00:21 luametatex
lrwxr-xr-x  1 evgeniysharapov  staff    10B Jul  3 00:21 mtxrun -> luametatex
-rw-r--r--  1 evgeniysharapov  staff   685K Jul  3 00:21 mtxrun.lua
lrwxr-xr-x  1 evgeniysharapov  staff    10B Jul 24 22:29 texlua -> luametatex
lrwxr-xr-x  1 evgeniysharapov  staff    80B Jul 24 22:33 texlua.lua -> /Users/evgeniysharapov/.ConTeXt/tex/texmf-context/scripts/context/lua/texlua.lua
[evgeniysharapov@SharMbp:~/.ConTeXt/tex/texmf-osx-64/bin]

When I run digestif I get following arg table

arg[0] = texlua
arg[1] = /Users/evgeniysharapov/.digestif/bin/digestif

Copy link
Owner

Choose a reason for hiding this comment

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

Okay, this is a bug in texlua.lua then. It's a kind of universal expectation that arg[1] is the first argument to the script, no matter how it was invoked. For comparison:

$ python -c "import sys; print(sys.argv)" 1 2 3
['-c', '1', '2', '3']
$ python -O -c "import sys; print(sys.argv)" 1 2 3
['-c', '1', '2', '3']
$ python -O -S -c "import sys; print(sys.argv)" 1 2 3
['-c', '1', '2', '3']

As you can see, the script doesn't see the previous argument -O etc.

But in any case it seems you can use luametatex --luaonly [lua_file] and it handles the arguments correctly.

Comment on lines +24 to +25
elseif util.is_command("mtxrun") then
-- this is a standalone ConTeXt installation
Copy link
Owner

Choose a reason for hiding this comment

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

I have mtxrun in my system and it's a TeXlive installation...

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I think the issue I experienced is unique to ConTeXt standalone installation.

@astoff
Copy link
Owner

astoff commented Aug 8, 2024

The link you provided in your comment says:

NOTE: You almost certainly want to install the newer ConTeXt LMTX. This guide is for installing the older, rarely-updated MkIV distribution.

Are you really referring to "ConTeXt standalone" or do you mean LMTX?

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.

2 participants