Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Development Setup

This guide walks you through setting up a local development environment for RouchDB.

Prerequisites

Rust Toolchain

RouchDB requires a recent stable Rust toolchain. Install it via rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Verify your installation:

rustc --version
cargo --version

The minimum supported Rust version (MSRV) is 1.88, declared as rust-version in the root Cargo.toml. The toolchain used for development and CI is pinned in rust-toolchain.toml; rustup installs it automatically the first time you run cargo inside the repository.

Docker (for integration tests)

Integration tests run against a real CouchDB instance. You need Docker and Docker Compose installed:

Docker is not required for building the project or running unit tests.

Clone and Build

git clone https://github.com/rubylab-app/rouchdb.git
cd rouchdb
cargo build

The workspace contains these crates:

CratePurpose
rouchdb-coreTypes, traits, revision tree, merge, collation, errors
rouchdb-adapter-memoryIn-memory adapter (testing and ephemeral use)
rouchdb-adapter-redbPersistent local storage via redb
rouchdb-adapter-httpCouchDB HTTP client adapter
rouchdb-changesStreaming changes feed
rouchdb-replicationCouchDB replication protocol
rouchdb-queryMango selectors and map/reduce views
rouchdb-viewsDesign documents and persistent view engine
rouchdbUmbrella crate that re-exports everything
rouchdb-serverCouchDB-compatible HTTP server (not published)
rouchdb-cliCommand-line tool (published; installs the rouchdb binary)
rouchdb-benchCriterion benchmarks (not published)
rouchdb-compat-testsCross-version tests against rouchdb 0.4.0 from crates.io (not published)

Running Unit Tests

Unit tests live inside each crate as #[cfg(test)] modules. They do not require any external services:

cargo test

This runs all unit tests across every crate in the workspace. To test a single crate:

cargo test -p rouchdb-core
cargo test -p rouchdb-adapter-memory

Docker Compose Setup for CouchDB

The project includes a docker-compose.yml at the repository root that starts a CouchDB 3.5.1 instance (the version CI tests against) on port 15984, with the admin admin:password. A one-shot couchdb-setup service then turns off CouchDB’s account lockout, which would otherwise lock the admin out after a few failed logins and fail the rest of the suite with 403.

Start CouchDB:

docker compose up -d

Wait for it to be healthy:

docker compose ps

You should see the couchdb service listed as healthy. CouchDB is now accessible at http://localhost:15984 with credentials admin:password.

To stop CouchDB when you are done:

docker compose down

Running Integration Tests

Integration tests verify RouchDB against a real CouchDB server. They are marked #[ignore = "requires CouchDB"] so they do not run during normal cargo test. Run them explicitly (see Testing):

docker compose up -d
bash scripts/test-couchdb.sh

Environment Variables

COUCHDB_URL

Override the default CouchDB connection URL used by integration tests. The default is:

http://admin:password@localhost:15984

To use a different CouchDB instance:

export COUCHDB_URL="http://myuser:mypass@couchdb.example.com:5984"
bash scripts/test-couchdb.sh

Editor Setup

RouchDB is a standard Cargo workspace. Any editor with rust-analyzer support works well:

  • VS Code with the rust-analyzer extension
  • RustRover (JetBrains)
  • Neovim / Helix with rust-analyzer LSP

No special configuration files are needed beyond what Cargo provides.