Most languages give you one binary and tell you to like it. rye is the general-purpose runtime: all the batteries, all the dependencies, all the contexts. That’s exactly what you want in a REPL, and exactly what you don’t always want when you ship a script.

l.rye (for “local Rye”) is a Rye script that builds a project-specific Rye interpreter. Give it a list of modules, and it compiles a leaner or fatter rye from the same source tree—removing what you don’t need, adding what you do, and optionally embedding your entry point or your own Go builtins.

It’s a work in progress. It’s also one of those small tools that changes how you think about the runtime.

TL;DR

  • l.rye builds a local rye binary from your own $RYE_HOME source tree.
  • lrye.mod lists modules (Go build tags) to include or exclude.
  • build embed_main bundles your main.rye into a single executable.
  • proj_builtins + a project_builtins/ folder lets you compile your own Go builtins in.
  • One script, no new toolchain: it’s just Rye driving go build.

Why build a bespoke interpreter?

Rye is small-minded about a big idea: a language should meet you at the size of the problem you’re solving.

The default rye carries a lot. There’s SQLite, Postgres, MySQL, MQTT, crypto, SSH, Telegram, Fyne interop, and more. In a REPL that’s a feature—everything is a keystroke away. In a shipped tool it’s a tax: bigger binary, more dependencies, more surface area, slower builds.

l.rye asks the obvious question: why compile in the modules you’ll never call?

A tiny CLI that only does os and http doesn’t need mysql. An embedded script doesn’t need the interactive terminal display. Compile a Rye that has exactly what the project needs, and nothing else.

The one-file spec: lrye.mod

Drop a file called lrye.mod next to your project. List the modules you want:

tiny http bleve

l.rye prefixes each name with b_ and passes them to Go as build tags. The line above becomes:

-tags "b_tiny b_http b_bleve"

Each module in the Rye source has two halves—builtins_x.go (guarded by b_x) and builtins_x_not.go (guarded by !b_x). So “including” a module is really about which _not.go stubs get compiled away and which real implementations get compiled in.

This is a deliberately boring mechanism. Build tags are old Go, well understood, zero magic. The interesting part is that Rye’s standard library was already structured this way, so l.rye mostly needs to thread the tags through.

Usage

# build a local rye with modules from lrye.mod
rye l.rye build

# or, if $RYE_HOME/bin is on your PATH
l.rye build

# on Linux you can even use the shebang
./l.rye build

It needs one environment variable:

export RYE_HOME="/path/to/rye"          # required
export RYE_FYNE_HOME="/path/to/rye-fyne" # only for Fyne builds

Commands:

  • build [tags] — build a local interpreter, output lrye.
  • build-fyne [tags] — build a Fyne GUI package.
  • package-fyne [tags] / package-fyne-apk [tags] — package for desktop / Android.
  • setup / help / version.

The optional tags argument is appended to the tags from lrye.mod, so you can pass one-off tags like embed_main without editing the file.

Embedding your entry point

A plain build gives you an interpreter that still expects to be pointed at a script. That’s fine for a project you run with lrye ..

But sometimes you want a real executable—double-click it, drop it on a server, ship it to someone who has never heard of Rye.

embed_main does that. Create a lrye.files listing the files to bake in:

%main.rye %lib.rye

Then:

l.rye build embed_main

l.rye copies those files into the Rye source’s build directory and compiles with the embed_main tag, producing a single main binary that runs your code as if you’d typed rye main.rye.

The honest caveat, straight from the script’s own header: it only embeds main.rye, and it’s proof-of-concept quality. But the shape is right—a Rye program and its runtime, fused into one artifact.

Bringing your own builtins

This is the part I find most interesting, because it crosses the usual boundary between “script” and “language implementation.”

Say your project has a builtin that doesn’t exist in Rye—a company-specific API, a hardware driver, a weird format. Normally you’d write it as a Rye library. But some things are awkward or slow as pure Rye; you want a native builtin.

l.rye lets you add one, per project, without forking Rye.

  1. Add the proj_builtins marker to lrye.mod:
tiny http proj_builtins
  1. Create a project_builtins/ folder and drop Go files in it. Each file is package projectbuiltins and defines a single RegisterProjectBuiltins function:
// project_builtins/mybuiltins.go
package projectbuiltins

import (
	"github.com/refaktor/rye/env"
	"github.com/refaktor/rye/evaldo"
)

func RegisterProjectBuiltins(ps *env.ProgramState) {
	evaldo.RegisterBuiltins2(map[string]*env.Builtin{
		"my-hello": {
			Argsn: 0,
			Fn: func(ps *env.ProgramState, arg0, arg1, arg2, arg3, arg4 env.Object) env.Object {
				return *env.NewString("hello from project builtins")
			},
		},
	}, ps, "project")
}
  1. Build as usual:
l.rye build

l.rye copies your files into a reserved projectbuiltins package in the Rye source, compiles with the proj_builtins tag, and registers your builtins after the standard set. Then my-hello is just a word:

print my-hello   ; hello from project builtins

The design keeps the escape hatch small. The Rye source has a tiny, permanent projectbuiltins package with a no-op Register by default. When you opt in, a tagged variant calls your RegisterProjectBuiltins. No marker in lrye.mod, no copy, no tag, no effect—the build is byte-for-byte a normal one.

What this makes possible

The three features—remove, embed, extend—compose:

  • A minimal CLI: tiny http and nothing else. Small binary, fewer dependencies.
  • A shipped tool: embed_main + only the modules you actually use.
  • A domain runtime: proj_builtins for the one native function your niche needs.
  • A Fyne app: the same spec drives build-fyne and package-fyne-apk.

None of it requires a new language, a plugin ABI, or a fork. It’s a Rye script driving go build, reading one small file, and respecting the build-tag structure that was already there.

Caveats (be honest)

  • Work in progress. The header says so. It’s proof-of-concept, mostly tested on Linux.
  • Linux-first. The Fyne and APK paths existed, then got rewritten; treat them as unstable.
  • embed_main is minimal. It embeds main.rye and not much more.
  • It builds from source. You need $RYE_HOME and a Go toolchain. This is not a prebuilt-binary manager; it’s a compiler for your runtime.
  • project_builtins is explicit. You opt in with a marker in lrye.mod; a stray folder without the marker is ignored, and a marker without .go files warns and builds normally.

Why this fits Rye’s personality

Rye already treats words, values, and failure as first-class and small. l.rye applies that same instinct to the runtime itself: instead of one universal binary, you get a runtime you can shrink, embed, or extend to fit the task.

It’s not a build system with plugins and manifests and a config DSL. It’s one file of tags, one folder of Go, and a Rye script that ties them together. The same way you’d write a short Rye program to solve a problem, you can now write a short Rye program to build the Rye that solves it.

Try it

# one-time setup
export RYE_HOME="/path/to/rye"
l.rye setup          # shows what env vars you need

# a minimal local rye
echo "tiny http" > lrye.mod
l.rye build
./lrye -do 'print "hello"'

Then add proj_builtins and a project_builtins/ file, and watch a word you wrote in Go become part of the language.

l.rye is early, but the idea is worth the attention: the interpreter is not a given—it’s another thing you can shape to the problem.