On Thu, Oct 18, 2012 at 10:32 AM, Reuben Thomas <r...@sc3d.org> wrote:
> Is there a way to require a particular version of a rock in a program?
> It seems there should be, since rocks can do it internally, but I
> can't find anything in the documentation…

You need to use the "luarocks.loader" module, which adds a
LuaRocks-enabled package loader to your require() function. It also
exposes a function called add_context, which allows you to specify a
dependency context. It's a bit clumsy, in which you need to specify an
exact version, with revision (it is mostly used internally by the
loader as it expands dependency, so I made it to be simple and fast)

~] luarocks install stdlib 27
...
~] luarocks install stdlib 25
...
~] eval `luarocks path`
~] lua -e 'require "std"; print(std.version)'
General Lua libraries / 27
~] lua -e 'loader = require"luarocks.loader";
loader.add_context("stdlib", "27-1"); require "std";
print(std.version)'
General Lua libraries / 27
~] lua -e 'loader = require"luarocks.loader";
loader.add_context("stdlib", "25-1"); require "std";
print(std.version)'
General Lua libraries / 25

-- Hisham
http://hisham.hm/

------------------------------------------------------------------------------
WINDOWS 8 is here. 
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
_______________________________________________
Luarocks-developers mailing list
Luarocks-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/luarocks-developers

Reply via email to