Skip to content

The beansc command

beansc is the Beans compiler and its command-line tool. It lexes, parses, checks, runs, and builds Beans code, and it hosts the package manager, the language server, and the debug adapter. The entry point is compiler/beans/main.b, driving compiler/beans/driver.b.

usage: beansc <lex|parse|check|mir|run> <file.b>...
beansc build [options] <file.b> [-o out]
beansc bindgen <header.h> -o <bindings.b> [options] [-- clang-options]
beansc pot init <module-name>
beansc pot add <dependency> [ref]
beansc pot add --system <pkg-config-name>
beansc pot remove <dependency>
beansc pot remove --system <pkg-config-name>
beansc pot update --system <pkg-config-name>
beansc pot <tidy|update [dependency]>
beansc upgrade
beansc doctor
beansc lsp-probe <file.b>:<line>:<col>
beansc lsp (language server on stdio)
beansc --version
build options:
--release -O3, NDEBUG
--lto link-time optimization
--target <triple> <supported target names>
--cpu <generic|native|name>
--features <+f,-f,...> enable or disable CPU features
--sysroot <path> target sysroot for a cross link
--cc <path> C driver to use (default clang)
--linker <name> pass -fuse-ld=<name>
--ar <path> static archive tool (default ar)
--header <path> write a C header for library exports
--emit <bin|obj|static|shared|ir>
--runtime <full|minimal|freestanding>
how much runtime; anything a profile
drops is refused at check time
--locked require exact beans.lock entries
--offline forbid dependency network access
CommandWhat it does
beansc --versionPrint the compiler, language, and runtime ABI versions.
beansc doctorReport what this install can build and how to fix what it cannot. Always exits 0.
beansc lex <file.b>...Dump the token stream.
beansc parse <file.b>...Parse and print the AST.
beansc check <file.b>Type-check. Prints <file>: ok or errors. Exit 1 on any error.
beansc mir <file.b>Print the checked, ownership-planned MIR.
beansc llvm <file.b>Print the LLVM IR native builds use.
beansc run <file.b> [-- args...]Check, then run on the reference interpreter.
beansc build [options] <file.b> [-o out]Compile to a native binary via LLVM/Clang.
beansc target <triple>Print one target’s layout and capability facts.
beansc bindgen <header.h> -o <bindings.b> [options] [-- clang-options]Generate Beans C declarations with Clang.
beansc pot init <module-name>Create beans.pot in the current directory without overwriting one.
beansc pot add <dependency> [ref]Add a Git dependency and write beans.lock.
beansc pot add --system <name>Add linker rows for an installed pkg-config C library.
beansc pot tidyResolve used dependencies and write beans.lock.
beansc pot remove <dependency>Remove a Git dependency and tidy beans.lock.
beansc pot remove --system <name>Remove generated linker rows for a C library.
beansc pot update [dependency]Refresh all locked dependencies, or one named.
beansc pot update --system <name>Refresh a C-library link block from pkg-config.
beansc upgradeUpgrade this Beans installation to the latest release.
beansc lspLanguage server on stdio.
beansc debug-adapterDebug adapter (DAP) on stdio.

Pages for each area:

beansc honors these environment variables:

VariableWhat it sets
BEANS_HOMEInstall root, and the prefix upgrade writes to.
BEANS_STDLIBStandard library root.
BEANS_RUNTIMEC runtime source.
BEANS_WASM_HOSTWebAssembly host source.
BEANS_ENCODINGEncoding bridge sources.
BEANS_CCC driver to use.
BEANS_WASM_CCC driver for WebAssembly.
BEANS_ARStatic archive tool.
BEANS_CPU_FEATURESAn allowlist that can only hide detected CPU features.
PATHUsed to find tools such as clang and the linker.

There is no formatter (beansc fmt does not exist, and there is no separate formatter tool) and no beansc test subcommand. See Exit codes and troubleshooting.