Install
provision toku with setup-toku.sh: download it, read it, run it, then verify with toku doctor
toku, the santoku command line, drives everything on this site, and it needs a one-time setup before it builds anything. setup-toku.sh, at https://santoku.dev/setup-toku.sh, is the only supported install. It builds lua 5.1.5 and luarocks 3.13.0 into ~/.local/share/toku and installs santoku-cli there.
Details
- The sources are sha256-verified, and the install root honors XDG_DATA_HOME.
- The script stores a copy of itself in the managed tree for later repairs and upgrades.
- The script records each run in manifest.lua in the managed root. Its components list names every part with its license, and toku license reads it: https://santoku.dev/santoku-make#santoku-make--third-party-notices
- Since setup-toku 0.0.64-1, each row that --resty or --node installed carries option = "resty" or option = "node". options records which of the two the run used.
- It writes nothing outside that directory: no symlinks and no shell rc edits. toku setup --uninstall removes the whole directory.
- It builds its own lua because santoku rocks pin lua == 5.1, and a system luarocks that targets a newer lua can't install them.
- Prerequisites: cc, make, tar, unzip, zip, curl, pkg-config and ps, with curl 7.71 or later, a sha256 tool (sha256sum, shasum or openssl), and the pkg-config modules blas, lapack and lapacke. The install commands for each package manager are at https://santoku.dev/install#install--install-the-prerequisites
- Since setup-toku 0.0.70-1, the script checks every prerequisite before it downloads anything. A missing tool or pkg-config module stops it with one message that lists each one, plus the install command for the host's package manager.
- Since santoku-make 10.2.0, a build without zip on PATH stops before it installs anything, because toku's built-rock cache packs each rock with luarocks pack, which runs zip. A rock that the cache can't store stops the build.
- Since setup-toku 0.0.68-1, curl is required. Neither the script nor the managed luarocks runs wget.
- Since setup-toku 0.0.65-1, every source download retries up to 5 times on any error, so one connection reset doesn't end the run.
- Since setup-toku 0.0.67-1, a download retries up to 8 times, waiting 1 s and then twice as long each time. A source that answers 5xx for up to about 4 minutes still downloads.
- A toku that reaches PATH some other way is a shell shim that execs a lua5.1 it doesn't own. On a distribution with no lua5.1 package it fails with exec: /usr/bin/lua5.1: not found. Run setup-toku.sh and use the toku it installs.
Install the prerequisites
setup-toku.sh needs a C toolchain, the archive tools, curl, pkg-config, and a BLAS, LAPACK and LAPACKE that ship pkg-config modules. The first command installs them, and the last adds what --resty and --node need.
$ apt-get install build-essential ca-certificates curl unzip zip pkg-config procps libopenblas-dev liblapacke-dev
$ apt-get install perl patch binutils xz-utils
$ dnf install gcc make tar unzip zip curl pkgconf-pkg-config procps-ng blas-devel lapack-devel
$ dnf install perl patch binutils xz
$ brew install pkg-config lapack
$ export PKG_CONFIG_PATH="$(brew --prefix lapack)/lib/pkgconfig"
$ brew install xz
$ pkg install clang make tar unzip zip curl pkg-config procps blas-openblas
$ pkg install perl patch patchelf nodejs
Details
- The script needs cc, make, tar, unzip, zip, curl, pkg-config and ps on PATH, and the pkg-config modules blas, lapack and lapacke.
- --resty also needs perl, patch and ar. On Android it also needs patchelf.
- --node also needs xz to unpack node. Where nodejs.org has no build, it needs node on PATH instead.
- On macOS, Homebrew's lapack is keg-only, so pkg-config finds it only through PKG_CONFIG_PATH.
- When something is missing, setup-toku.sh prints the command for the package manager it finds: pkg on Android, then apt-get, dnf or brew.
Download and run
Download setup-toku.sh, read it, run it, then run toku doctor. The script builds the managed toolchain and prints where everything landed, plus an optional PATH line.
$ curl -fSLO https://santoku.dev/setup-toku.sh
$ less setup-toku.sh
$ sh setup-toku.sh
[setup] fetching https://www.lua.org/ftp/lua-5.1.5.tar.gz
[setup] building lua 5.1.5 (Linux)
[setup] fetching https://luarocks.github.io/luarocks/releases/luarocks-3.13.0.tar.gz
[setup] building luarocks 3.13.0
[setup] installing santoku-cli into /home/you/.local/share/toku/rocks
[setup] installing luacheck 1.2.0-1 into /home/you/.local/share/toku/rocks
[setup] managed toolchain ready at /home/you/.local/share/toku
[setup] managed toku: /home/you/.local/share/toku/rocks/bin/toku
[setup] optional PATH wiring:
[setup] export PATH="/home/you/.local/share/toku/rocks/bin:...:$PATH"
[setup] verify with: toku doctor
$ export PATH="$("$HOME/.local/share/toku/rocks/bin/toku" setup --path):$PATH"
$ toku doctor
toku doctor
running toku: /home/you/.local/share/toku/rocks/lib/luarocks/rocks-5.1/santoku-cli/8.0.1-1/bin/toku
root: /home/you/.local/share/toku (present)
pinned versions: lua 5.1.5, luarocks 3.13.0, openresty 1.31.1.1, node 24.22.0
...
managed lua: /home/you/.local/share/toku/lua/bin/lua (Lua 5.1)
...
shell PATH wiring: managed bin dirs are on your PATH
build prerequisites: ok
skills: /home/you/.claude/skills (10 current)
no problems found
Details
- The script also installs luacheck 1.2.0-1 into the managed rocks tree, because the check stage of toku test runs it. Without luacheck on PATH, that stage stops and says to install it or pass --skip-check.
- PATH wiring is yours to do. The script never edits shell configuration.
- toku doctor reports the managed root, the pinned and built versions, the resolved lua and luarocks, and PATH wiring. It exits nonzero when anything is wrong.
- Since santoku-cli 6.0.2, toku doctor checks the build prerequisites by running the stored setup-toku.sh --check, so it checks the same list that setup checks and prints its install line. A stored setup-toku.sh from before setup-toku 0.0.70-1 has no --check, and doctor says to download the current one.
- sh setup-toku.sh --check checks the prerequisites for the tree at --root and changes nothing. It exits 1 with the list when anything is missing.
Install into a container
setup-toku.sh --container installs toku-web and toku-lib, which run toku in the toku-web and toku-lib images with the current directory mounted at the same path. Its only prerequisite is podman or docker.
$ curl -fsSL https://santoku.dev/setup-toku.sh | sh -s -- --container
$ export PATH="$HOME/.local/share/toku/rocks/bin:$PATH"
$ toku-web test
$ toku-web start --iterate
$ toku-lib test
$ curl -fsSL https://santoku.dev/setup-toku.sh | sh -s -- --check --container
$ toku setup --container
Details
- It picks podman when podman is on PATH, else docker. It needs no compiler, BLAS or other host tools.
- It fetches toku-container.sh, toku-lib.sh, toku-web.sh, toku-lib.dockerfile and toku-web.dockerfile for santoku-make 13.1.0-1 from https://releases.santoku.dev/santoku-make/13.1.0-1/ into $XDG_DATA_HOME/toku/container/13.1.0-1.
- It builds the toku-lib and toku-web images, links toku-lib and toku-web into $XDG_DATA_HOME/toku/rocks/bin, the native install's bin directory, and prints the PATH line.
- A rerun skips an image whose dev.santoku.make label names that santoku-make, and rebuilds one whose label doesn't. So a newer setup-toku.sh rebuilds the images. --rebuild rebuilds them anyway.
- --check --container checks that both images carry that santoku-make and both commands link to its wrappers. It changes nothing.
- Since santoku-cli 8.0.0, toku setup --container reruns the stored setup-toku.sh with --container, so it builds the images of the santoku-make that copy pins.
- The wrappers and their flags: https://santoku.dev/start-web#start-web--run-toku-in-a-container
Pin the santoku-cli version
--cli-version VERSION, or the TOKU_CLI_VERSION environment variable, makes setup-toku.sh install that santoku-cli instead of the newest. Use it to pin a build to one known version.
$ sh setup-toku.sh --cli-version 8.0.1-1
$ TOKU_CLI_VERSION=8.0.1-1 sh setup-toku.sh
ARG SETUP_TOKU_VERSION=0.0.79-1
ARG SETUP_TOKU_SHA256=82825e3b63ad3882a2d89b2c114cdeb54712e2ee70465453fe46d0e76e635318
ARG TOKU_CLI_VERSION=8.0.1-1
RUN --mount=type=cache,target=/root/.local/share/toku/cache \
curl -fsSL --retry 8 --retry-all-errors -o /tmp/setup-toku.sh \
https://releases.santoku.dev/setup-toku/$SETUP_TOKU_VERSION/setup-toku.sh \
&& echo "$SETUP_TOKU_SHA256 /tmp/setup-toku.sh" | sha256sum -c - \
&& sh /tmp/setup-toku.sh --cli-version "$TOKU_CLI_VERSION"
Details
- The flag wins when both are set.
- A rerun reinstalls when the installed toku reports a different version. Setup fails if toku still reports another version afterwards.
- A version without a revision, such as 3.4.4, matches any revision.
- In a container build, pass the version as a build argument, so a change to the pin rebuilds that layer.
- In a container build, also pin setup-toku.sh itself. Each release stays at https://releases.santoku.dev/setup-toku/<version>/setup-toku.sh and never changes, so a sha256 check holds.
- The current release is setup-toku 0.0.79-1 with santoku-cli 8.0.1-1.
Keep downloads across container builds
Mount one build cache at the toku cache directory on the setup-toku.sh RUN and on every toku RUN. A rebuilt layer then takes its sources and built rocks from the cache.
ENV XDG_DATA_HOME=/opt
ENV PATH=/opt/toku/rocks/bin:/opt/toku/luarocks/bin:/opt/toku/lua/bin:$PATH
ARG SETUP_TOKU_VERSION=0.0.79-1
ARG SETUP_TOKU_SHA256=82825e3b63ad3882a2d89b2c114cdeb54712e2ee70465453fe46d0e76e635318
ARG TOKU_CLI_VERSION=8.0.1-1
RUN --mount=type=cache,target=/opt/toku/cache \
curl -fsSL --retry 8 --retry-all-errors -o /tmp/setup-toku.sh \
https://releases.santoku.dev/setup-toku/$SETUP_TOKU_VERSION/setup-toku.sh \
&& echo "$SETUP_TOKU_SHA256 /tmp/setup-toku.sh" | sha256sum -c - \
&& sh /tmp/setup-toku.sh --cli-version "$TOKU_CLI_VERSION" \
&& rm -rf /opt/toku/src /tmp/setup-toku.sh
WORKDIR /app
COPY . .
RUN --mount=type=cache,target=/opt/toku/cache toku build --env prod
Details
- The cache directory is $TOKU_CACHE, or $XDG_DATA_HOME/toku/cache when TOKU_CACHE is unset. With ENV XDG_DATA_HOME=/opt it is /opt/toku/cache.
- setup-toku.sh and toku keep their downloads in downloads/ under the cache directory. setup-toku.sh names each file by its sha256, and uses a file there with the right sha256 with no network request.
- toku keeps built rocks in built/ under the same directory, so one mount serves both.
- $XDG_DATA_HOME/toku/src holds only the extracted sources, so rm -rf it after setup-toku.sh to keep the image small.
- Every download gives up on a transfer that moves less than 1 KB a second for 30 seconds, then retries, up to 8 times.
Managed OpenResty for web projects
--resty, or toku setup --resty, builds a pinned OpenResty into ~/.local/share/toku/openresty with Google's ngx_brotli compiled in. toku build, start and test then use it with no OPENRESTY_DIR to set.
$ sh setup-toku.sh --resty
$ toku openresty -v
$ toku resty -e 'ngx.say(ngx.config.nginx_version)'
Details
- openssl, pcre2 and zlib build from pinned sources and link statically.
- ngx_brotli makes brotli, brotli_types and brotli_static work in every nginx.conf.
- Every download is sha256-checked.
- The build needs perl, patch and ar, and takes several minutes. On Android it also needs patchelf.
- Later runs keep the build, since the manifest records it.
- A tree built before ngx_brotli was added gets its OpenResty rebuilt on the next run of setup-toku.sh.
- Two sha256-pinned nginx patches serve santoku.resty.accept, which closes a worker's listeners. With them, each worker that nginx starts listens again on a reuseport socket that an earlier process shut down. A worker whose reuseport socket another process shut down closes that socket and takes no more connections on it.
- After the build, the script copies nginx's headers into ~/.local/share/toku/openresty/nginx/include. santoku-resty needs them to build santoku.resty.accept and santoku.resty.ring.
- A tree that lacks either patch or the headers gets its OpenResty rebuilt on the next run.
- toku puts the OpenResty bin directory on its own PATH, and sets OPENRESTY_DIR to it when that variable is unset. An explicit OPENRESTY_DIR still wins.
- toku resty runs the resty script, and toku openresty passes its arguments to the nginx binary.
- toku doctor checks the OpenResty version and that it starts.
Managed node for wasm tests
--node, or toku setup --node, adds node 24.22.0 to ~/.local/share/toku/node. toku test --wasm and toku install --bundled --wasm run that recorded node.
$ sh setup-toku.sh --node
[setup] managed node: /home/you/.local/share/toku/node/bin/node (v24.22.0)
$ toku doctor
...
managed node: /home/you/.local/share/toku/node/bin/node (24.22.0)
...
Details
- On x86_64 and arm64 Linux and macOS, the script downloads node from nodejs.org and checks its sha256. The unpack needs xz.
- Where nodejs.org has no build, the script records the node on PATH instead, and fails unless that node is version 24 or newer.
- Later runs keep the node, since the manifest records the node and its path.
- Without a recorded node, toku test --wasm and toku install --bundled --wasm stop with "wasm tests need the managed node; run: toku setup --node".
- toku puts the managed node's bin directory on its own PATH.
- toku doctor reports the managed node line and flags a version that differs from the pin.
How toku uses the toolchain
Inside its own process, toku prepends the managed bin directories to PATH, so toku builds call the managed lua and luarocks. Nothing outside that process changes.
$ toku lua scripts/load.lua
$ toku luarocks list
$ toku luac -o out.luac in.lua
$ toku setup --path
Details
- Until setup has run, every command that needs lua or luarocks errors and names the step to run. That covers toku lua, toku luarocks and the whole project lifecycle.
- To reach the same pair from your shell, wire PATH as the transcript at https://santoku.dev/install#install--download-and-run does. Or symlink the binaries you want out of the directories that toku setup --path prints.
- toku lua is the managed interpreter, with the managed rocks tree on its package path.
- toku luarocks and toku luac pass through to the managed luarocks and luac.
- toku bundle --luac-default compiles bytecode with the managed luac, so a system luac built for a newer Lua can't corrupt a bundle.
- toku setup --path prints the managed bin directories, joined with colons.
Doctor, repair, uninstall
toku doctor is the first health check: it names the command that fixes each problem it finds. toku setup and toku setup --repair rerun the stored setup script, and --uninstall removes the managed tree.
$ toku doctor
$ toku setup
$ toku setup --repair
$ toku setup --path
$ toku setup --uninstall
Details
- setup-toku.sh stores a copy of itself at ~/.local/share/toku/setup-toku.sh, so the managed tree always carries the script that built it.
- toku setup with no flag reruns that copy to complete a partial tree, and is safe to repeat. It also rebuilds luarocks when the tree's luarocks was built with other patches than the copy applies, and the installed rocks tree stays.
- A tree built before setup-toku 0.0.66-1 has an unpatched luarocks. Its first failed download ends the run with LuaRocks 3.13.0 bug, where it should try the next mirror. Run the current setup-toku.sh once to store the new copy and rebuild luarocks.
- From setup-toku 0.0.68-1, the managed luarocks downloads every rockspec, manifest and rock source with curl. It doesn't use LuaSocket, LuaSec or wget, whether or not the tree holds the luasocket and luasec rocks.
- It retries a download when curl fails without a 4xx answer: a dropped connection, a body cut short, a 5xx answer, or a transfer that moves no data for 30 seconds. It retries 8 times and waits 1, 2, 4 and up to 128 seconds. Each retry prints a warning. A 4xx answer fails on the first request, and the error names the URL and curl's last message.
- A tree built by an older setup-toku fails on the first dropped connection, so run the current setup-toku.sh once there too. A rock whose source is a git URL clones with git, and that clone doesn't retry.
- toku setup --repair reruns it with --rebuild. lua and luarocks rebuild at the pinned versions, with the managed OpenResty and node when they're installed. santoku-cli reinstalls, and the installed rocks tree stays.
- If the stored copy is missing, or pins different versions or another luarocks patch set than the installed santoku-cli, toku setup errors before it changes the tree. The error points you back to this page for the current script.
- toku doctor reports the managed root, the lua and luarocks in effect, and tree health. It also reports version drift against the pins, a luarocks built with other patches than santoku-cli pins, your shell PATH wiring and the build prerequisites. It exits nonzero when it finds a problem.
- Since santoku-cli 8.0.0, toku doctor compares the santoku-make that the stored setup-toku.sh pins with the installed santoku-make. A mismatch is a problem, because toku setup --container would build the older release's images. Download the current setup-toku.sh, read it, then run it.
- toku setup --path prints the managed bin directories for PATH wiring.
- toku setup --uninstall removes ~/.local/share/toku entirely.
Upgrade santoku-cli
luarocks install into the managed rocks tree upgrades santoku-cli. toku doctor afterwards names the step that brings the tree to what the new version pins.
$ luarocks --tree="$HOME/.local/share/toku/rocks" install santoku-cli
$ luarocks --tree="$HOME/.local/share/toku/rocks" install santoku-make
$ toku doctor
Details
- When the stored setup script already carries the new pins, toku doctor names toku setup --repair. That rebuilds lua and luarocks at the pinned versions, plus the managed OpenResty and node when they're installed, and keeps the installed rocks.
- A newer santoku-cli can pin a newer setup script than the copy stored in the tree. toku doctor then names the download. Run the current setup-toku.sh once. It rebuilds luarocks or OpenResty when only their patches changed, and it stops and asks for --rebuild when a pinned version changed.
- Upgrade santoku-make the same way when a page names a minimum for it. luarocks resolves an already-satisfied constraint by installing nothing. A santoku-cli newer than the santoku-make beside it can then fail inside toku with a nil-call traceback instead of a version message.
- toku doctor reports both versions.