Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Run Lua on Heroku!

branch: master

This branch is 0 commits ahead and 0 commits behind master

Octocat-spinner-32 bin set LD_LIBRARY_PATH February 28, 2013
Octocat-spinner-32 include lua lib and include February 05, 2012
Octocat-spinner-32 lib lua lib and include February 05, 2012
Octocat-spinner-32 opt install rock binaries into the bin directory November 08, 2012
Octocat-spinner-32 test accept luarocks config table in the rockspec September 04, 2012
Octocat-spinner-32 .gitignore fetch dependencies from luarocks February 05, 2012
Octocat-spinner-32 Makefile install from a rockspec instead of package.lua February 08, 2012
Octocat-spinner-32 Update November 07, 2012

Heroku buildpack: Lua

This is a Heroku buildpack for Lua apps.

It comes bundled with Lua 5.1 and LuaRocks

Read a tutorial at


Create an app with the buildpack:

$ heroku create --buildpack


In order to describe the dependencies of you application you must create a rockspec for it.

The first file found that matches *.rockpsec in the root directory will be used. Don't put multiple ones in the root directory otherwise it might get confused.

The buildpack only looks at the dependency information. Meaning you don't have to follow the entire rockspec specification. Minimally, your rockspec could look something like this:

-- my_app.rockspec
dependencies = {
  "xavante >= 2.2.1",

As shown above, if you want to include external rockspec or rock files by URL you can place them in the dependencies table. (This is not supported by LuaRocks, only by this buildpack).

This file must exist, even if you have no dependencies. The rockspec is parsed in prepare.moon.

The buildpack installs the dependencies to packages/ and Lua to bin/lua.

The bin/ directory is added to the PATH on initial install so you can run Lua directly.

Additionally, LUA_PATH and LUA_CPATH environment variables are set to point to where the dependencies are installed so you can require them with no extra work.

Example App

Use Xavante for a quick web server:

-- web.lua
require "xavante"

port = ...

xavante.HTTP {
  server = { host = "*", port = tonumber(port) },
  defaultHost = {
    rules = {
        match = ".",
        with = function(req, res)
          res.headers["Content-type"] = "text/html"
          res.content = "hello world, the time is: " ..
          return res


Tell Heroku to spawn your web server by creating a file called Procfile:

web:     lua web.lua $PORT

After pushing, if the web server doesn't start automatically, tell Heroku to start it:

$ heroku scale web=1


If you were using the first incarnation of this buildpack the paths were not set automatically. In order to upgrade your app use heroku config to manually set the config vars described in the release script.

Something went wrong with that request. Please try again.