// CONTENTS Part 02 · Build, run, scale

// PART 02

Building from source

Chapter 09 / 56 3 min read English Part 02 of 14

botserver builds from one workspace with Cargo; the variables are system libraries, toolchain settings and feature selection. This page is the build recipe; the profile semantics are in Runtime model and product profiles.

1. Toolchain and system dependencies

# Rust via rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

# Ubuntu/Debian build prerequisites
sudo apt update
sudo apt install -y clang lld mold build-essential pkg-config \
    libssl-dev libpq-dev cmake git

The repository’s .cargo/config.toml sets jobs = 3 and the clang+mold linker for x86_64-unknown-linux-gnu; keep it as the source of truth and do not override with -j unless the host cannot fit it (documented exception: CARGO_BUILD_JOBS=1 on hosts where rustc is SIGKILLed).

Fedora/RHEL equivalents: clang, lld, mold, openssl-devel, postgresql-devel, cmake. macOS: brew install postgresql openssl cmake git plus xcode-select --install. Windows: Visual Studio Build Tools with the C++ workload; libpq is expected at C:\pgsql\pgsql\lib (set in .cargo/config.toml).

Desktop/Tauri builds additionally need the GTK stack (libwebkit2gtk-4.1-dev and friends). Server builds never do — if you see a webkit error, you are building a desktop feature by accident.

2. Clone

git clone --recursive https://github.com/GeneralBots/gb.git
cd gb
# or, on an existing clone:
git submodule update --init --recursive

3. Build

Goal Command
Development (default, debug) cargo build -p botserver
Smallest chat server cargo build -p botserver --no-default-features --features minimal
Wide office server cargo build -p botserver --no-default-features --features full
Desktop sidecar cargo build -p botserver --no-default-features --features desktop-local
Type gate only cargo check -p <crate>
Static-link experiment RUSTFLAGS='-C target-feature=+crt-static' cargo build --release

Binary locations: target/debug/botserver (development — the documented way to run locally) and target/release/botserver (packaging only). The release profile uses lto, opt-level = "z", strip and panic = "abort"; a release build is for the installer pipeline, not for a dev machine.

Verify:

./target/debug/botserver --version
# botserver 7.1.2

4. Run

cd botserver
./target/debug/botserver --noconsole > botserver.log 2>&1 &
curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/health   # 200
tail -f botserver.log          # bootstrap progress, drive_monitor, tool registration

First boot provisions the stack (PostgreSQL, Valkey, Vault, drive, directory, optional local LLM). .env at the repository root holds only VAULT_* variables; every other credential is read from Vault at boot.

5. Troubleshooting

Symptom Cause and fix
linker 'clang' not found install clang/lld, or remove the custom linker block; check ~/.cargo/config.toml for stale overrides
could not find native library pq install libpq-dev; set PQ_LIB_DIR on macOS/Windows
openssl-sys build failure install libssl-dev pkg-config
rustc killed during build memory pressure — CARGO_BUILD_JOBS=1 cargo build on that host
webkit2gtk build error you are building a desktop feature; either install the GTK 4.1 stack or drop the feature
“ignoring invalid dependency ‘botserver’ which is missing a lib target” something depends on the binary crate; test crates must depend on botlib/botcore, and integration tests spawn the binary as a process
#[derive(RustEmbed)] folder … does not exist the embed path needs the interpolate-folder-path feature on rust-embed

6. What CI does differently

CI (the alm-ci Forgejo runner) builds in a persistent workspace with sccache (RUSTC_WRAPPER=sccache), pushes the built binary to the bot container over SSH, and restarts via systemd. Never compile directly for production or copy binaries by hand — push and let CI deploy.

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move