Skip to main content

Prerequisites

Before building Prisma Engines, ensure you have the following installed:
1

Install Rust Toolchain

Install the latest stable version of Rust. You can get the toolchain at rustup or use your package manager.
2

Linux: Install OpenSSL

On Linux systems, OpenSSL is required:
3

Install direnv

Install direnv to automatically load environment variables:
Make sure direnv is hooked into your shell.
4

Allow direnv in Repository

Navigate to the repository root and allow direnv:
Alternatively, you can manually load the environment variables defined in ./.envrc, but using direnv is recommended.
5

Optional: Install Node.js and pnpm

Required for building driver adapters:
  • Node.js ≥ 20
  • pnpm package manager

Environment Setup

The repository uses .envrc to configure essential environment variables:
You can create a .envrc.local file (gitignored) for local overrides.

Optional: Nix Users

The repository includes a shell.nix file for Nix users. If you have Nix installed and direnv configured, all dependencies will be automatically set up. To disable Nix in environments where it’s pre-installed (e.g., Gitpod):

Building the Engines

Build All Engines (Debug Mode)

To build all engines in debug mode:
Binaries will be located in target/debug/:

Build All Engines (Release Mode)

For optimized production binaries:
Release binaries will be in target/release/.

Build Specific Components

Build Query Compiler Wasm

The query compiler is a library crate that compiles to Wasm for the JavaScript runtime:
Output location: query-compiler/query-compiler-wasm/pkg/

Build Driver Adapters

Driver adapters enable the query compiler to work with JavaScript database drivers:
1

Ensure prisma/prisma Repository

The driver adapters build process requires the main Prisma repository as a sibling:
2

Build Driver Adapters Kit

Build Targets Reference

Makefile Targets

Clean Build Artifacts

Code Quality

Format Code

Run Linter (Clippy)

Pedantic CI Check

Emulate the CI compilation checks locally:
This runs:
  1. cargo fmt -- --check (formatting validation)
  2. cargo clippy --all-features --all-targets -Dwarnings (lint checks)
  3. Additional Wasm target checks
Fix compiler and clippy diagnostics before addressing formatting issues.

Optimizing Build Performance

Parallel rust-analyzer Builds

When rust-analyzer runs cargo check, it locks the build directory. To avoid this:
  1. Open VSCode settings
  2. Search for “Check on Save: Extra Args”
  3. Add a custom target directory:

Using LLD Linker (Linux)

The .envrc automatically configures the faster LLD linker on Linux if available:

Troubleshooting

OpenSSL Not Found (Linux)

If you encounter OpenSSL linking errors:

direnv Not Loading

Ensure direnv is properly hooked in your shell config:

Wasm Build Fails

Ensure the Wasm target is installed:

Next Steps

Once you’ve successfully built the engines: