* [NTG-context] My new module can't find its data files
@ 2025-09-09 13:50 Gavin via ntg-context
2025-09-09 14:34 ` [NTG-context] " Henning Hraban Ramm
2025-09-09 14:51 ` Wolfgang Schuster
0 siblings, 2 replies; 4+ messages in thread
From: Gavin via ntg-context @ 2025-09-09 13:50 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Gavin
Hi List,
I wrote a module that draws globes, but I’ve run into a problem as I get it ready to share. The module works fine for documents that are in the same folder as the module’s various files, but it doesn’t work for documents that are anywhere else. ConTeXt finds and loads the module, but it can’t find the data files containing the map data.
The module’s files and directory structure can all be found at:
https://github.com/Sophias-Compass/luageo
It is organized according to the TDS instructions for modules on the wiki.
Here’s what is going wrong, in more detail.
I put my pre-release luageo module into texmf-local so that I could use it in other documents. This works if the other document is in the luageo directory with the module, but it doesn’t work if the other document is anywhere else. The module still loads. (From a failed log file…)
modules > 'luageo' is loaded
open source > level 2, order 3, name '/Users/Gavin/context-osx-arm64/tex/texmf-local/luageo/tex/context/third/luageo/t-luageo.mkxl’
But the module can’t find the map data files.
lua error > lua error on line 41 in file /Users/Gavin/context-osx-arm64/tex/texmf-local/luageo/tex/context/third/luageo/t-luageo.mkxl:
token call, execute: cannot open data/iles.lua: No such file or directory
The main module file, t-luageo.mkxl, contains a line to load t-luageo.lmt, which has the necessary Lua code.
\registerctxluafile{t-luageo}{}
The Lua code states that the map data should be found in the data directory.
moduledata = moduledata or { }
local geo = { }
moduledata.geo = geo
geo.datafolder = "data/“
I’m not actually sure what all those lines do. (I think they were written by Hans when he was helping me earlier.) Later, the Lua code loads the data.
dofile("data/iles.lua")
dofile("data/ameriquenord.lua”)
…
This works if the document using the module in in the module folder, but it breaks if the document is somewhere else.
Any suggestions? The full failed log file is below.
Thanks!
Gavin
resolvers | formats | executing runner 'run luametatex format': /Users/Gavin/context-osx-arm64/tex/texmf-osx-arm64/bin/luametatex --jobname="./luageo-manual.tex" --socket --shell-escape --fmt=/Users/Gavin/context-osx-arm64/tex/texmf-cache/luametatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luametatex/cont-en.fmt --lua=/Users/Gavin/context-osx-arm64/tex/texmf-cache/luametatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luametatex/cont-en.lui --c:currentrun=1 --c:fulljobname="./luageo-manual.tex" --c:input="./luageo-manual.tex" --c:kindofrun=1 --c:maxnofruns=9 --c:synctex --c:texmfbinpath="/Users/Gavin/context-osx-arm64/tex/texmf-osx-arm64/bin"
system >
system > ConTeXt ver: 2025.08.20 10:30 LMTX fmt: 2025.8.22 int: english/english
system >
system > 'cont-new.mkxl' loaded
open source > level 1, order 1, name '/Users/Gavin/context-osx-arm64/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system > beware: some patches loaded from cont-new.mkiv
close source > level 1, order 1, name '/Users/Gavin/context-osx-arm64/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system > files > jobname './luageo-manual', input './luageo-manual.tex', result './luageo-manual'
fonts > latin modern fonts are not preloaded
languages > language 'en' is active
system > synctex functionality is enabled, expect 5-10 pct runtime overhead!
open source > level 1, order 2, name './luageo-manual.tex'
modules > 'luageo' is loaded
open source > level 2, order 3, name '/Users/Gavin/context-osx-arm64/tex/texmf-local/luageo/tex/context/third/luageo/t-luageo.mkxl'
lua error > lua error on line 41 in file /Users/Gavin/context-osx-arm64/tex/texmf-local/luageo/tex/context/third/luageo/t-luageo.mkxl:
token call, execute: cannot open data/iles.lua: No such file or directory
stack traceback:
[C]: in global 'dofile'
...texmf-local/luageo/tex/context/third/luageo/t-luageo.lmt:108: in local 'code'
...m64/tex/texmf-context/tex/context/base/mkiv/util-lua.lua:97: in field 'loadedluacode'
...m64/tex/texmf-context/tex/context/base/mkiv/luat-env.lua:108: in field 'luafilechunk'
...m64/tex/texmf-context/tex/context/base/mkxl/luat-cod.lmt:82: in field 'registercode'
[ctxlua]:1: in main chunk
31 % [luageo]
32 % [\s!format=metafun,
33 % \s!extensions=\v!yes,
34 % \s!initializations=\v!yes,
35 % \c!method=\s!double]
36
37 \startMPdefinitions
38 loadmodule "luageo" ;
39 \stopMPdefinitions
40
41 >> \registerctxluafile{t-luageo}{}
42
43 % % Module's ConTeXt code from here to \protect. Example of a namespace and a module parameter
44
45 % \installnamespace {luageo}
46 % \installcommandhandler \????luageo {luageo} \????luageo
47
48 % \setupmodule[color=newman]
49 % \processaction[\currentmoduleparameter{color}]
50 % [ newman=>\def\BColor{red},
51 % gottlieb=>\def\BColor{yellow},
mtx-context | fatal error: return code: 1
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* [NTG-context] Re: My new module can't find its data files
2025-09-09 13:50 [NTG-context] My new module can't find its data files Gavin via ntg-context
@ 2025-09-09 14:34 ` Henning Hraban Ramm
2025-09-09 14:51 ` Wolfgang Schuster
1 sibling, 0 replies; 4+ messages in thread
From: Henning Hraban Ramm @ 2025-09-09 14:34 UTC (permalink / raw)
To: ntg-context
Am 09.09.25 um 15:50 schrieb Gavin via ntg-context:
> I wrote a module that draws globes, but I’ve run into a problem as I get it ready to share. The module works fine for documents that are in the same folder as the module’s various files, but it doesn’t work for documents that are anywhere else. ConTeXt finds and loads the module, but it can’t find the data files containing the map data.
>
> The module’s files and directory structure can all be found at:
> https://github.com/Sophias-Compass/luageo
Thank you for this interesting contribution!
> dofile("data/iles.lua")
> dofile("data/ameriquenord.lua”)
AFAIK, dofile is a Lua function, it doesn’t know anything about TDS.
Did you try loading the files with a ConTeXt function like
context.runfile("iles.lua")
?
It might need a "mtxrun --generate" before to update the file database.
HTH
Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* [NTG-context] Re: My new module can't find its data files
2025-09-09 13:50 [NTG-context] My new module can't find its data files Gavin via ntg-context
2025-09-09 14:34 ` [NTG-context] " Henning Hraban Ramm
@ 2025-09-09 14:51 ` Wolfgang Schuster
2025-09-09 18:39 ` Gavin via ntg-context
1 sibling, 1 reply; 4+ messages in thread
From: Wolfgang Schuster @ 2025-09-09 14:51 UTC (permalink / raw)
To: ntg-context
Am 09.09.2025 um 15:50 schrieb Gavin via ntg-context:
> Hi List,
>
> I wrote a module that draws globes, but I’ve run into a problem as I get it ready to share. The module works fine for documents that are in the same folder as the module’s various files, but it doesn’t work for documents that are anywhere else. ConTeXt finds and loads the module, but it can’t find the data files containing the map data.
>
> The module’s files and directory structure can all be found at:
>
> https://github.com/Sophias-Compass/luageo
>
> It is organized according to the TDS instructions for modules on the wiki.
>
> Here’s what is going wrong, in more detail.
>
> I put my pre-release luageo module into texmf-local so that I could use it in other documents. This works if the other document is in the luageo directory with the module, but it doesn’t work if the other document is anywhere else. The module still loads. (From a failed log file…)
>
> modules > 'luageo' is loaded
> open source > level 2, order 3, name '/Users/Gavin/context-osx-arm64/tex/texmf-local/luageo/tex/context/third/luageo/t-luageo.mkxl’
>
> But the module can’t find the map data files.
>
> lua error > lua error on line 41 in file /Users/Gavin/context-osx-arm64/tex/texmf-local/luageo/tex/context/third/luageo/t-luageo.mkxl:
> token call, execute: cannot open data/iles.lua: No such file or directory
>
> The main module file, t-luageo.mkxl, contains a line to load t-luageo.lmt, which has the necessary Lua code.
>
> \registerctxluafile{t-luageo}{}
>
> The Lua code states that the map data should be found in the data directory.
>
> moduledata = moduledata or { }
> local geo = { }
> moduledata.geo = geo
> geo.datafolder = "data/“
>
> I’m not actually sure what all those lines do. (I think they were written by Hans when he was helping me earlier.) Later, the Lua code loads the data.
>
> dofile("data/iles.lua")
> dofile("data/ameriquenord.lua”)
dofile(resolvers.findfile("..."))
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* [NTG-context] Re: My new module can't find its data files
2025-09-09 14:51 ` Wolfgang Schuster
@ 2025-09-09 18:39 ` Gavin via ntg-context
0 siblings, 0 replies; 4+ messages in thread
From: Gavin via ntg-context @ 2025-09-09 18:39 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Gavin
Thanks Wolfgang! Now my module works.
Thanks to both Hraban and Wolfgang for all on the module writing documentation on the wiki and in presentations. These answered about 1000 questions that I didn’t have to ask on the mailing list.
My module doesn’t do much, but it does it well. I’ll make a little manual and upload it to contextgarden.net.
My primary goal with this project is encourage collaboration among module authors – especially new authors! Aside from the data files, my module is tiny, with only about 300 lines of code. I would like it to be a model that others can easily copy on GitHub to start their own modules, especially modules that include ConTeXt, MetaPost, and Lua code working together. I would love to get advice on how to make it a better template, as well as how to make it a more functional map-drawing tool.
Thanks again!
Gavin
> On Sep 9, 2025, at 8:51 AM, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:
> Am 09.09.2025 um 15:50 schrieb Gavin via ntg-context:
>>
>> dofile("data/iles.lua")
>> dofile("data/ameriquenord.lua”)
>
> dofile(resolvers.findfile("..."))
>
> Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-09 18:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-09 13:50 [NTG-context] My new module can't find its data files Gavin via ntg-context
2025-09-09 14:34 ` [NTG-context] " Henning Hraban Ramm
2025-09-09 14:51 ` Wolfgang Schuster
2025-09-09 18:39 ` Gavin via ntg-context
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).