Using LuaRocks to distribute scripts

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using LuaRocks to distribute scripts

aryajur
Hello,
       I am looking for a way to distribute a Lua script using LuaRocks. The script Lua file will get installed in the directory which is in the Lua package.path. Can LuaRocks install it in a path that is also accessible to Lua on the command line:

> lua myscript.lua

should work. 

I was looking at the "Creating a rock" document here: https://github.com/keplerproject/luarocks/wiki/Creating-a-rock#Building_a_module
but it seems to assume that it is a module I think.

What should I do different to install a script so Lua can run it directly?

Thanks,
Milind
Reply | Threaded
Open this post in threaded view
|

Re: Using LuaRocks to distribute scripts

Nagaev Boris
On Thu, Jun 16, 2016 at 1:26 AM, Milind Gupta <[hidden email]> wrote:

> Hello,
>        I am looking for a way to distribute a Lua script using LuaRocks. The
> script Lua file will get installed in the directory which is in the Lua
> package.path. Can LuaRocks install it in a path that is also accessible to
> Lua on the command line:
>
>> lua myscript.lua
>
> should work.
>
> I was looking at the "Creating a rock" document here:
> https://github.com/keplerproject/luarocks/wiki/Creating-a-rock#Building_a_module
> but it seems to assume that it is a module I think.
>
> What should I do different to install a script so Lua can run it directly?
>
> Thanks,
> Milind


Add the following to the "build" table of the rockspec:

build = {
    install = {
        bin = {
            "myscript.lua",
        },
    },
}

It installs shell wrapper called "myscript.lua" to the directory
<luarocks_root>/bin, e.g. to /usr/local/bin or to ~/.luarocks/bin (if
--local is in use). The wrapper calls lua with the arguments needed to
run your script as a program.

The directory <luarocks_root>/bin should be added to PATH. In
up-to-date luarocks you can do it with the following command:

$ eval $(luarocks path --bin)

Then you can call your script directly:

$ myscript.lua

--


Best regards,
Boris Nagaev

Reply | Threaded
Open this post in threaded view
|

Re: Using LuaRocks to distribute scripts

aryajur
Thank you!

Milind

On Wed, Jun 15, 2016 at 3:43 PM, Nagaev Boris <[hidden email]> wrote:
On Thu, Jun 16, 2016 at 1:26 AM, Milind Gupta <[hidden email]> wrote:
> Hello,
>        I am looking for a way to distribute a Lua script using LuaRocks. The
> script Lua file will get installed in the directory which is in the Lua
> package.path. Can LuaRocks install it in a path that is also accessible to
> Lua on the command line:
>
>> lua myscript.lua
>
> should work.
>
> I was looking at the "Creating a rock" document here:
> https://github.com/keplerproject/luarocks/wiki/Creating-a-rock#Building_a_module
> but it seems to assume that it is a module I think.
>
> What should I do different to install a script so Lua can run it directly?
>
> Thanks,
> Milind


Add the following to the "build" table of the rockspec:

build = {
    install = {
        bin = {
            "myscript.lua",
        },
    },
}

It installs shell wrapper called "myscript.lua" to the directory
<luarocks_root>/bin, e.g. to /usr/local/bin or to ~/.luarocks/bin (if
--local is in use). The wrapper calls lua with the arguments needed to
run your script as a program.

The directory <luarocks_root>/bin should be added to PATH. In
up-to-date luarocks you can do it with the following command:

$ eval $(luarocks path --bin)

Then you can call your script directly:

$ myscript.lua

--


Best regards,
Boris Nagaev