← garnet-lang.org  ·  Install  ·  Mini-Spec  ·  GitHub ↗

Getting Started

Install → a running first program in about two minutes. The default installer now targets the published v0.5.0 release path; v0.4.2 remains available as the previous release.

Garnet is a research-grade prototype (v0.x.x), not a production-complete language. This page is the honest happy path; the install section covers per-OS specifics and fallbacks.

1Prerequisites

None for the prebuilt path — the universal installer pulls a release package verified against SHA256SUMS. The source path needs Rust 1.75+.

2Install

$ curl --proto '=https' --tlsv1.2 -sSf https://garnet-lang.org/install.sh | sh

This verifies the download, extracts garnet, and prints where it landed. Add that bin dir to your PATH if the installer warns it isn't there.

3Scaffold a project

$ garnet new --template cli my_app
  created my_app/ (cli template)
$ cd my_app

You get a small, real project:

my_app/
├── Garnet.toml          # project manifest
├── README.md
├── src/main.garnet      # entry point
└── tests/test_main.garnet

4Read the entry point

src/main.garnet is deliberately tiny — and it teaches the one idea that makes Garnet different: capabilities.

@caps()
def main() {
  println("Hello from my_app!")
  println("")
  println("Edit src/main.garnet to change this message.")
  println("Run `garnet run src/main.garnet` to execute.")
  0
}

The @caps() annotation declares the OS authority this program may exercise. Empty means pure computation. Need files, time, network, or subprocesses? You write @caps(fs), @caps(time), @caps(net), @caps(proc) — and every primitive call site is checked at compile time against that declaration. Authority is explicit, not ambient.

5Test it

$ garnet test
  test test_arithmetic ... ok
  test test_string_interpolation ... ok

  test result: ok. 2 passed; 0 failed; in 2 file(s)

The template ships with two green starter tests so you start from a known-good state.

6Run it

$ garnet run src/main.garnet
  Hello from my_app!

  Edit src/main.garnet to change this message.
  Run `garnet run src/main.garnet` to execute.
  => 0

The trailing => 0 is main's return value (its exit code).

7Make a change

Edit the first println in src/main.garnet, then re-run garnet run src/main.garnet. That edit/run loop is the whole inner cycle.

Where to go next

Try the other starters too: garnet new --template web-api and garnet new --template agent-orchestrator — each scaffolds, tests, and runs the same way.