Implementation:Duckdb Duckdb Setup Ubuntu Build Env
| Field | Value |
|---|---|
| source | DuckDB Repository |
| domains | Build_System, DevOps |
| last_updated | 2026-02-07 |
Overview
Concrete tool for provisioning an Ubuntu build environment provided by shell scripts.
Description
The setup_ubuntu1804.sh script is a self-contained shell script provided in the DuckDB repository that automates the complete provisioning of an Ubuntu-based build environment. It installs all required compilers, build tools, caching utilities, system libraries, and Python packages needed to compile DuckDB from source.
The script uses apt-get as the primary package manager to install system-level dependencies, followed by pip for Python-based build utilities. It is designed to run on Ubuntu 18.04 and later versions, targeting both developer workstations and CI/CD runners.
Key packages installed by the script include:
| Package | Purpose |
|---|---|
| build-essential | GCC, G++, libc headers, and GNU Make |
| cmake | Cross-platform build system generator |
| ninja-build | High-performance build executor |
| ccache | Compiler output caching for faster rebuilds |
| python3-dev | Python 3 development headers for Python bindings |
| libssl-dev | OpenSSL development headers for cryptographic operations |
The script is idempotent: running it multiple times on the same system will not cause errors, as apt-get install gracefully handles already-installed packages.
Usage
This script should be run as the first step before building DuckDB from source. It is required in the following scenarios:
- Setting up a fresh Ubuntu system for DuckDB development
- Provisioning a new CI/CD build agent
- Restoring a build environment after a system update that may have removed packages
- Onboarding a new contributor who needs a working build environment
The script requires root privileges (or sudo) because it installs system packages via apt-get.
Code Reference
Source location: scripts/setup_ubuntu1804.sh
Signature (key apt-get install command):
sudo apt-get install -y \
build-essential \
cmake \
ninja-build \
ccache \
python3-dev \
python3-pip \
libssl-dev \
libcurl4-openssl-dev \
liblz4-dev \
zlib1g-dev \
unixodbc-dev \
git
Import (invocation):
bash scripts/setup_ubuntu1804.sh
I/O Contract
| Direction | Description |
|---|---|
| Inputs | A fresh Ubuntu 18.04+ system with internet access and sudo privileges. No prior development tools are assumed to be installed. |
| Outputs | A fully configured build environment with GCC/G++ compiler toolchain, CMake build generator, Ninja build executor, ccache compiler cache, Python 3 with pip, and all required system library development headers. After execution, the system is ready to run cmake and make (or ninja) to compile DuckDB from source.
|
Usage Examples
Example 1: Running the setup script on a fresh Ubuntu system
# Clone the DuckDB repository
git clone https://github.com/duckdb/duckdb.git
cd duckdb
# Run the environment setup script
bash scripts/setup_ubuntu1804.sh
Example 2: Verifying that tools are installed correctly after running the script
# Verify GCC is installed
gcc --version
# Expected output: gcc (Ubuntu ...) 7.5.0 or later
# Verify CMake is installed
cmake --version
# Expected output: cmake version 3.x.x
# Verify Ninja is installed
ninja --version
# Expected output: 1.x.x
# Verify ccache is installed
ccache --version
# Expected output: ccache version 3.x.x or later
# Verify Python 3 is available
python3 --version
# Expected output: Python 3.x.x
Example 3: Proceeding with the DuckDB build after environment setup
# After running setup_ubuntu1804.sh, build DuckDB
cd duckdb
mkdir -p build/release
cd build/release
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ../..
ninja