Skip to main content

Toolchain Management

RBS provides a hermetic toolchain system that automatically downloads, caches, and manages all external tools and runtimes your project needs. No manual installation required — RBS handles everything.

Why Hermetic Toolchains?

  • Reproducibility: Every developer and CI server uses the exact same tool versions.
  • No System Dependencies: No need to install Java, Python, Node.js, or any other tool system-wide.
  • Version Isolation: Different projects can use different versions of the same tool without conflict.
  • Automatic Caching: Tools are downloaded once and cached for future use.

How It Works

  1. You declare toolchains in WORKSPACE.rbs.
  2. RBS automatically downloads the correct version for your platform.
  3. Tools are cached in .rbs/toolchains/.
  4. Build rules use the managed toolchains — never system-installed tools.

Declaring Toolchains

Language Toolchains

RBS provides built-in toolchain rules for common languages:

Custom Toolchains

For tools not covered by built-in rules, use the low-level primitives:

native.http_file — Download a Single File

native.http_archive — Download and Extract an Archive

native.tool_binary — Declare a Tool from an Archive

register_toolchain — Register for Use in Rules

Using Toolchains in Rules

In Built-in Rules

Built-in rules automatically use the appropriate registered toolchain:

In Custom Rules

Access toolchains via ctx.tools:

Platform-Aware Downloads

RBS automatically selects the correct download URL based on the current platform using select():

Available Platform Labels

PlatformLabel
macOS ARM64//platforms:darwin_arm64
macOS x64//platforms:darwin_amd64
Linux ARM64//platforms:linux_arm64
Linux x64//platforms:linux_amd64
Windows x64//platforms:windows_amd64

Toolchains vs External Dependencies

It’s important to understand the difference between toolchains and external dependencies:
AspectToolchainsExternal Dependencies
WhatBuild tools (compilers, runtimes, linters)Language packages (libraries, frameworks)
ExamplesJDK, Node.js, Python, protocSpring Boot, Express, Django, React
Defined withjava_toolchain, http_archive, tool_binaryjava_repository, nodejs_repository, py_repository
Stored in.rbs/toolchains/.rbs/external-deps/
Used byBuild rules (compilation, execution)Application code (imports, runtime)

Example: Both Together

Caching and Offline Builds

Cache Location

All toolchains are cached in .rbs/toolchains/:

Offline Mode

Once all toolchains are downloaded, RBS can run without network access:

Cache Management

Integrity Verification

Use SHA256 checksums to verify downloaded toolchains:
If the checksum doesn’t match, RBS will refuse to use the download, protecting against tampered artifacts.