Building babashka

January 31, 2026 ยท View on GitHub

Prerequisites

  • Install lein for producing uberjars

  • Download GraalVM. Currently we use Oracle GraalVM 25.

  • For Windows, installing Visual Studio 2019 with the "Desktop development with C++" workload is recommended.

  • Set $GRAALVM_HOME to the GraalVM distribution directory. On macOS this can look like:

    export GRAALVM_HOME=~/Downloads/graalvm-jdk-21.0.0.1/Contents/Home
    

    On linux:

    export GRAALVM_HOME=~/Downloads/graalvm-jdk-21.0.0.1
    

    On Windows, from the Visual Studio 2019 x64 Native Tools Command Prompt or cmd.exe (not Powershell):

    set GRAALVM_HOME=%USERPROFILE%\Downloads\graalvm-ce-jdk-21.0.0.1
    

    If you are not running from the x64 Native Tools Command Prompt, you will need to set additional environment variables using:

    call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
    

Clone repository

NOTE: the babashka repository contains submodules. You need to use the --recursive flag to clone these submodules along with the main repo.

$ git clone https://github.com/babashka/babashka --recursive

To update later on:

$ git submodule update --init --recursive

Build

Run the uberjar and compile script:

$ script/uberjar
$ script/compile

To configure max heap size you can use:

$ export BABASHKA_XMX="-J-Xmx6500m"

Note: setting the max heap size to a low value can cause the build to crash or take long to complete.

Alternative: Build inside Docker

To build a Linux version of babashka, you can use docker build, enabling the desired features via --build-arg like this:

docker build --build-arg BABASHKA_FEATURE_JDBC=true --target BASE -t bb-builder .
container_id=$(docker create bb-builder)
docker cp $container_id:/opt/bb bb # copy to ./bb on the host file system
docker rm $container_id

NOTE: If you get Error: Image build request failed with exit status 137 then check whether Docker is allowed to use enough memory (e.g. in Docker Desktop preferences). If it is, then increase the memory GraalVM can use, for example by adding --build-arg BABASHKA_XMX="-J-Xmx8g" (or whatever Docker has available, bigger than the default).

Windows

Run script\uberjar.bat followed by script\compile.bat.

Static

To compile babashka as a static binary for linux, set the BABASHKA_STATIC environment variable to true.

Musl and zlib

Static compilation requires musl and zlib. Since pre-built musl distributions are no longer available on musl.cc, both libraries need to be built from source.

When using graalvm/setup-graalvm GitHub Action with native-image-musl: 'true', musl 1.2.4 and zlib 1.2.13 are automatically built from source. This adds approximately 30 seconds to the build time. See setup-graalvm#114 for details.

Feature flags

Babashka supports the following feature flags:

NameDescriptionDefault
BABASHKA_FEATURE_CSVIncludes the clojure.data.csv librarytrue
BABASHKA_FEATURE_JAVA_NET_HTTPIncludes commonly used classes from the java.net.http packagetrue
BABASHKA_FEATURE_JAVA_NIOIncludes commonly used classes from the java.nio packagetrue
BABASHKA_FEATURE_JAVA_TIMEIncludes commonly used classes from the java.time packagetrue
BABASHKA_FEATURE_TRANSITIncludes the transit-clj librarytrue
BABASHKA_FEATURE_XMLIncludes the clojure.data.xml librarytrue
BABASHKA_FEATURE_YAMLIncludes the clj-yaml librarytrue
BABASHKA_FEATURE_HTTPKIT_CLIENTIncludes the http-kit client librarytrue
BABASHKA_FEATURE_HTTPKIT_SERVERIncludes the http-kit server librarytrue
BABASHKA_FEATURE_CORE_MATCHIncludes the clojure.core.match librarytrue
BABASHKA_FEATURE_HICCUPIncludes the hiccup librarytrue
BABASHKA_FEATURE_TEST_CHECKIncludes the clojure.test.check librarytrue
BABASHKA_FEATURE_SPEC_ALPHAIncludes the clojure.spec.alpha library (WIP)false
BABASHKA_FEATURE_JDBCIncludes the next.jdbc libraryfalse
BABASHKA_FEATURE_SQLITEIncludes the sqlite-jdbc libraryfalse
BABASHKA_FEATURE_POSTGRESQLIncludes the PostgresSQL JDBC driverfalse
BABASHKA_FEATURE_HSQLDBIncludes the HSQLDB JDBC driverfalse
BABASHKA_FEATURE_ORACLEDBIncludes the Oracle JDBC driverfalse
BABASHKA_FEATURE_DATASCRIPTIncludes datascriptfalse
BABASHKA_FEATURE_LOGGINGIncludes clojure.tools.logging with taoensso.timbre as the default implementationtrue
BABASHKA_FEATURE_PRIORITY_MAPIncludes clojure.data.priority-maptrue

Note that httpkit server is currently experimental, the feature flag could be toggled to false in a future release.

To disable all of the above features, you can set BABASHKA_LEAN to true.

Here is an example commit that can be used as a checklist when you want to create a new feature flag.

HyperSQL

To compile babashka with the next.jdbc library and the embedded HyperSQL database:

$ export BABASHKA_FEATURE_JDBC=true
$ export BABASHKA_FEATURE_HSQLDB=true
$ script/uberjar
$ script/compile

Note: there is now a pod for working with HyperSQL.

PostgresQL

To compile babashka with the next.jdbc library and a PostgresQL driver:

$ export BABASHKA_FEATURE_JDBC=true
$ export BABASHKA_FEATURE_POSTGRESQL=true
$ script/uberjar
$ script/compile

Note: there is now a pod for working with PostgreSQL.