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 Desktop (macOS / Windows)
- Docker Engine (Linux)
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:
| Crate | Purpose |
|---|---|
rouchdb-core | Types, traits, revision tree, merge, collation, errors |
rouchdb-adapter-memory | In-memory adapter (testing and ephemeral use) |
rouchdb-adapter-redb | Persistent local storage via redb |
rouchdb-adapter-http | CouchDB HTTP client adapter |
rouchdb-changes | Streaming changes feed |
rouchdb-replication | CouchDB replication protocol |
rouchdb-query | Mango selectors and map/reduce views |
rouchdb-views | Design documents and persistent view engine |
rouchdb | Umbrella crate that re-exports everything |
rouchdb-server | CouchDB-compatible HTTP server (not published) |
rouchdb-cli | Command-line tool (published; installs the rouchdb binary) |
rouchdb-bench | Criterion benchmarks (not published) |
rouchdb-compat-tests | Cross-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.