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
- You declare toolchains in
WORKSPACE.rbs. - RBS automatically downloads the correct version for your platform.
- Tools are cached in
.rbs/toolchains/. - 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 viactx.tools:
Platform-Aware Downloads
RBS automatically selects the correct download URL based on the current platform usingselect():
Available Platform Labels
| Platform | Label |
|---|---|
| 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:| Aspect | Toolchains | External Dependencies |
|---|---|---|
| What | Build tools (compilers, runtimes, linters) | Language packages (libraries, frameworks) |
| Examples | JDK, Node.js, Python, protoc | Spring Boot, Express, Django, React |
| Defined with | java_toolchain, http_archive, tool_binary | java_repository, nodejs_repository, py_repository |
| Stored in | .rbs/toolchains/ | .rbs/external-deps/ |
| Used by | Build rules (compilation, execution) | Application code (imports, runtime) |
Example: Both Together
Caching and Offline Builds
Cache Location
All toolchains are cached in.rbs/toolchains/: