Get started with Lema
Install Lema, run an HTTPS echo server, and change its response.
The echo starter answers each request with what it received. You edit a handler that turns a request into a response; Lema’s library supplies TLS 1.3 and HTTP/1.1. The installed package includes the CLI and its matching VM. You do not need Rust or a source checkout.
Use an Apple Silicon Mac or a supported Linux x86_64 machine. Check the tested platforms and prerequisites before installing. You can also copy the setup prompt into a coding agent and have it follow these public instructions while preserving your existing projects.
Install Lema
Choose one installation method. Both install the same CLI and VM release.
Direct installation
The echo starter needs OpenSSL and a TLS 1.3-capable curl. On a Mac with Homebrew, install these tools with brew install openssl@3 curl. On the supported Debian baseline, use sudo apt install bubblewrap openssl curl. Ubuntu also needs the documented namespace-policy prerequisite. Lema’s setup guide explains discovery and host permissions.
Download the installer, then run it:
curl --proto '=https' --tlsv1.2 -fsSLo install-lema.sh https://www.lema-lang.org/install.sh
sh install-lema.shThe installer checks the downloaded archive and prints the installed version, location, license, and a command to add Lema to your PATH. Run that printed command in this terminal. It does not edit your shell configuration or require sudo.
Homebrew
If you use Homebrew, add Lema’s public tap and install the package:
brew tap lorenalabs/lema https://brew.lema-lang.org/homebrew-lema.git
if brew help trust >/dev/null 2>&1; then
brew trust --formula lorenalabs/lema/lema
fi
brew install lorenalabs/lema/lemaThe trust step approves only Lema’s formula and is skipped when Homebrew has no trust command.
Homebrew also installs the OpenSSL and curl tools needed by the HTTPS example. On Linux, Homebrew requires an x86_64 CPU with SSSE3 support; Lema still needs the operating system’s bubblewrap package. The machine setup guide covers prerequisites and custom installation locations.
Prepare the runtime
Check the installed pair, then download and configure the remaining runtime resources:
lema --version
lema build-info --check-worker
lema setuplema setup installs the pinned Lean checker and standard-library pack, then checks the selected runtime configuration in its sandbox. The first download and check can take several minutes. Continue when the command exits successfully and prints setup complete; selected runtime: ....
An existing configuration is preserved and checked. If setup reports library pack: NOT ready or runtime ...: NOT ready, follow that diagnostic and retry; setup recovery explains the common cases. A runtime check alone does not mean the library pack is ready.
Create and run the echo project
Choose a directory for your projects. Lema creates a new echo directory and refuses to overwrite one that already exists:
mkdir -p "$HOME/lema-projects"
cd "$HOME/lema-projects"
lema new echo
cd echo
lema run echolema new echo creates Handler.lean, Server.lean, a project store, and a development certificate under .lema/deploy/. It adopts the standard-library modules as checked (Lema release) and checks your starter code locally with Lean. The first project and app build may take several minutes.
Wait for this line before sending a request:
lema: serving echo at https://127.0.0.1:8443Lema prints it after the worker has bound the listener. It also prints a curl command using a TLS 1.3-capable client discovered on your machine. Copy that complete command into another terminal and run it twice. It has this form; the executable path may differ:
curl --noproxy '*' --http1.1 --tlsv1.3 --tls-max 1.3 -k https://127.0.0.1:8443/hello -d 'hi'On macOS, use the absolute curl path Lema prints, because the system curl may not support this TLS connection. Each response contains the request method, path, headers and body. For example, with the curl version varying by machine:
POST /hello
Host: 127.0.0.1:8443
User-Agent: curl/...
Accept: */*
Content-Length: 2
Content-Type: application/x-www-form-urlencoded
hiThe -k option accepts the starter’s self-signed development certificate for this local test. It is not a production certificate. --noproxy '*' keeps this loopback request out of any configured proxy.
Change the response
Press Ctrl-C in the app terminal. This stops the HTTPS app and restarts the project’s background codebase server, which handles authoring commands. Open Handler.lean and find the successful request branch in respond:
| .ok q => (ok, ⟨(echo q).toArray⟩)Replace that branch with a fixed response:
| .ok _ => (ok, ⟨(bytes "Hello from Lema\n").toArray⟩)Add the changed module, compare the handler’s output with the expected bytes, and start the app again:
lema add Handler.lean
lema test Handler.report --expect $'Hello from Lema\n'
lema run echoThe $'...' quoting works in bash and zsh and includes the final newline. lema add checks the module and re-adds its dependents; an invalid type or proof stops it with a source diagnostic. The test reports passed only when the sample response matches the expected bytes, and exits unsuccessfully on a mismatch.
Wait for serving, then repeat the printed curl command. The response is now Hello from Lema. When you finish, press Ctrl-C to stop the app. Run lema stop in the project if you also want to stop its background codebase server.
If the app does not start
If port 8443 is occupied, stop the process you intended to replace, or choose another development port:
lema dev-cert echo --port 8444
lema run echoUse the new URL and curl command printed by Lema. A failed bind, early worker exit, or readiness timeout reports an error instead of serving; it asks you to check the port and run log before retrying. The project server is restarted after the worker stops. Correct the reported cause before trying again.
For a build mismatch after updating Lema, see Update or uninstall Lema. Stop active apps before restarting the codebase server with the new CLI.
Continue with Select a contract and prove it to give an implementation a checked behavioral contract, or try lema new hello for a command-line project.
Lema v0.3.2 · Updated 29 October 2026 · Version and compatibility