On Mon, Oct 11, 2010 at 11:28 AM, Jerome Vuarand
<[email protected]> wrote:
> 2010/10/11 steve donovan <[email protected]>:
>> On Mon, Oct 11, 2010 at 3:35 PM, Jerome Vuarand
>> <[email protected]> wrote:
>>> First, how is namespace conflict handled by LuaRocks?
>>
>> In the old days, there was no problem; any package would specify
>> exactly what it needed, and it would get that what it needed when it
>> said 'require', all done with the magic of 'luarocks.require'. And it
>> still works like that with explicit luarocks.require, certainly on the
>> local tree. The system was designed around that whole concept, and
>> only later (due to peer pressure) that modules got copied to the
>> regular Lua module paths.
>
> While I welcomed the change, when conflicts occurs I'd like to specify
> which version of a module to use. The documentation only specify that
> once "luarocks.loader" has been required, dependency trees will be
> respected, but it doesn't tell how to specify such a dependency at
> runtime (my script use rocks, but is now one itself).
It's not the nicest interface ever, but this works:
local loader = require("luarocks.loader")
loader.add_context("luaposix", "5.1.7-2")
local posix = require("posix")
print(posix.version)
add_context inserts the specified module and all its dependencies in
the loader's dependency tree -- unfortunately it currently requires
the specific rock version as a second argument.
LuaRocks used to allow extra arguments to require which allowed
version ranges to be specified, etc. but that went away when we
switched to just adding a loader. I think in the future we need to
make add_context smarter and use it within LuaRocks itself to make
sure it is using the right dependencies.
-- Hisham
_______________________________________________
Luarocks-developers mailing list
[email protected]
http://lists.luaforge.net/cgi-bin/mailman/listinfo/luarocks-developers