lualatex / luamplib

generic TeX package - including MetaPost code in LuaTeX documents
http://ctan.org/pkg/luamplib
16 stars 11 forks source link

luamplib fails to load when texbin is not on PATH #74

Closed rpspringuel closed 6 years ago

rpspringuel commented 6 years ago

I'm working on a plugin for an App on a Mac which calls lualatex to typeset a small snippet of code in order to make use of the result inside the App (if it's pertinent, it's a render frame in Scribus). As a "security precaution" Mac apps are not given access to a full shell instance with all the normal customizations that one would find when starting Terminal. In particular PATH=/usr/bin:/bin:/usr/sbin:/sbin. As a result, lualatex has to be invoked with the full path (/Library/TeX/texbin/lualatex), and when that is done it works fine. However, if the document attempts to load the luamplib package, then the following error occurs:

This is LuaTeX, Version 1.0.4 (TeX Live 2017) 
 restricted system commands enabled.
(./Untitled.tex
LaTeX2e <2017-04-15>
(using write cache: /Users/ss/Library/texlive/2017/texmf-var/luatex-cache/gener
ic)(using read cache: /usr/local/texlive/2017/texmf-var/luatex-cache/generic /U
sers/ss/Library/texlive/2017/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.121 seconds
Babel <3.18> and hyphenation patterns for 1 language(s) loaded.
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2017/texmf-dist/tex/latex/base/size10.clo(load luc: /usr/lo
cal/texlive/2017/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc
))) (/usr/local/texlive/2017/texmf-dist/tex/luatex/luamplib/luamplib.stylstat(./luatex) failed ...
./luatex: No such file or directory
Assertion failed: (ret), function remove_dots, file ../../../texk/kpathsea/progname.c, line 316.
Abort trap: 6

The test document was:

\documentclass{article}
\usepackage{luamplib}
\begin{document}
Hello.
\end{document}

Is there anyway to load the luamplib package with the PATH given above, or do I have to find a way to modify the PATH from inside the App?

Note: I can duplicate the error in Terminal simply by setting PATH as indicated.

macOS 10.13.4 TeXLive 2017 fully updated (to frozen state)

dohyunkim commented 6 years ago

While attempting to tackle the issue reported, it seems that a temporary fix has been found. Please try again the test file after correcting a line in luamplib.lua:

--- /usr/local/texlive/2018/texmf-dist/tex/luatex/luamplib/luamplib.lua 2018-04-07 06:37:07.000000000 +0900
+++ luamplib/luamplib.lua   2018-04-15 08:23:55.000000000 +0900
@@ -261,7 +261,7 @@

 local randomseed = nil

-local mpkpse = kpse.new("luatex", "mpost")
+local mpkpse = kpse.new(arg[0], "mpost")

 local special_ftype = {
   pfb = "type1 fonts",
rpspringuel commented 6 years ago

That does indeed fix the problem. Thank you.