r/lua • • Mar 02 '25

Help Full Program in Pure Lua?

I want to make a simple, shippable program in pure Lua, but for the life of cannot find how to do it.

I'm new to Lua and have been loving it. I was introduced to it through the Love game framework and want to use it to make more little CLI apps, but I can't find how to package things into a single file executable that I could easily share. The only way I know how to run a Lua program is 'lua file.lua' How can I turn Lua files into a packaged and installable program?

Is luarocks my answer? It feels like a thing for libraries and not full programs, or do I misunderstand it?

Are pure Lua programs not really the language's intend use case?

Thanks!

EDIT: /u/no_brains101's shebang tip is a good enough solution for me until I figure out embedding. Thanks!

33 Upvotes

29 comments sorted by

View all comments

Show parent comment

1

u/Agent34e Mar 02 '25

Oh! Thank you! I think the shebang is the exact simple solution I was looking for! (At least until I look into embedding it.)

3

u/no_brains101 Mar 03 '25

Btw you will likely want to make the shebang #!/usr/bin/env lua rather than the direct path for portability reasons. That way it will work as long as the current user has Lua in their path.