From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/58596 Path: news.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: problem with package.path Date: Sat, 08 May 2010 08:35:53 +0200 Message-ID: <4BE50649.9080201@elvenkind.com> References: <20100504082814.GA6991@gaston.couberia.bzh> <4BE32294.8020908@wxs.nl> <20100507071535.GA3537@gaston.couberia.bzh> <4BE3D4D3.3030904@elvenkind.com> <4BE3D965.5010902@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040100020803050103060502" X-Trace: dough.gmane.org 1273300566 10530 80.91.229.12 (8 May 2010 06:36:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 8 May 2010 06:36:06 +0000 (UTC) Cc: mailing list for ConTeXt users To: Hans Hagen Original-X-From: ntg-context-bounces@ntg.nl Sat May 08 08:36:05 2010 connect(): No such file or directory Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OAddp-00014U-JE for gctc-ntg-context-518@m.gmane.org; Sat, 08 May 2010 08:36:01 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 6F174C9C1F; Sat, 8 May 2010 08:36:00 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4C9o7JTNFXmP; Sat, 8 May 2010 08:35:57 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id C6208C9CA5; Sat, 8 May 2010 08:35:57 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 44F91C9CA5 for ; Sat, 8 May 2010 08:35:56 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id w07Nm9PXulmq for ; Sat, 8 May 2010 08:35:54 +0200 (CEST) Original-Received: from smtp-vbr15.xs4all.nl (smtp-vbr15.xs4all.nl [194.109.24.35]) by balder.ntg.nl (Postfix) with ESMTP id 23F76C9C1F for ; Sat, 8 May 2010 08:35:54 +0200 (CEST) Original-Received: from [192.168.178.26] (boo.demon.nl [83.163.247.99]) (authenticated bits=0) by smtp-vbr15.xs4all.nl (8.13.8/8.13.8) with ESMTP id o486Zrxj062299; Sat, 8 May 2010 08:35:53 +0200 (CEST) (envelope-from taco@elvenkind.com) User-Agent: Thunderbird 2.0.0.23 (X11/20090822) In-Reply-To: <4BE3D965.5010902@wxs.nl> X-Virus-Scanned: by XS4ALL Virus Scanner X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:58596 Archived-At: This is a multi-part message in MIME format. --------------040100020803050103060502 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Hans Hagen wrote: > On 7-5-2010 10:52, Taco Hoekwater wrote: >> Peter M=FCnster wrote: >>> On Thu, May 06 2010, Hans Hagen wrote: >>> >>>>> \startbuffer[test] >>>>> bla =3D nil >>>>> \stopbuffer >>>>> \savebuffer[test][../mytest.lua] >>>>> \starttext >>>>> \startluacode >>>>> package.path =3D "../?.lua;;" >>>>> require("mytest") >>>>> \stopluacode >>>>> \stoptext >>>> dofile "../mytest.lua" >>> >>> Bad example... >>> >>> mytest.lua is a module, so it must be loaded with require: >> >> You cannot always replace 'require' with 'dofile', and for >> this reason it is important that package.path actually works >> as explained in the lua manual. (escrito had similar problems, >> and other external lua modules will run into it as well). >=20 > well, package path is supported (as is cpath) so it's more a question o= f=20 > why that paths fails .. maybe we need to explicitly assume ";" instead=20 > of the platform separator (tests on my machine work ok as windows has ;= =20 > as separator) >=20 > you can test this with adding an explcit ";" to >=20 > libpaths =3D file.split_path(_path_,";") >=20 > in data-lua.lua For me on linux, this change should make it work (package.path indeed contains semicolons). However, require() is still broken: ! LuaTeX error /opt/tex/texmf-local/tex/context/base/l-file.lua:133: bad=20 argument #1 to 'gsub' (string expected, got nil) stack traceback: [C]: in function 'gsub' /opt/tex/texmf-local/tex/context/base/l-file.lua:133: in=20 function 'split_path' /opt/tex/texmf-local/tex/context/base/data-lua.lua:36: in=20 function 'clibpaths' /opt/tex/texmf-local/tex/context/base/data-lua.lua:97: in=20 function [C]: in function 'require'
:2: in main chunk. }inserted text> ...equire('testmodule') -- fails \dodostartluacode ...d \directlua \zerocount {#1}} l.5 \stopluacode Test files are attached. The definition of package.libpaths I used: function package.libpaths() print (_path_, package.path) if not _path_ or package.path ~=3D _path_ then _path_ =3D package.path libpaths =3D file.split_path(_path_,';') print (table.serialize(libpaths)) end return libpaths end And it prints out: nil=20 ./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lu= a;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua t=3D{ "./?.lua", "/usr/local/share/lua/5.1/?.lua", "/usr/local/share/lua/5.1/?/init.lua", "/usr/local/lib/lua/5.1/?.lua", "/usr/local/lib/lua/5.1/?/init.lua", } But it looks like mkiv is not happy with the split path, as it goes on trying clibpaths(). Also, I ran into another problem: if the module has the same name as the base input file, package.libpaths is not called at all (initially the module was called 'tryme.lua'). Best wishes, Taco --------------040100020803050103060502 Content-Type: text/plain; name="testmodule.lua" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="testmodule.lua" module 'testmodule' return {} --------------040100020803050103060502 Content-Type: application/x-tex; name="tryme.tex" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tryme.tex" \starttext \startluacode local tryme = require('testmodule') -- fails \stopluacode \stoptext --------------040100020803050103060502 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --------------040100020803050103060502--