rent
Getting started

Install Rent

Rent is currently distributed directly from a checked-out workspace. Applications use a local Cargo path dependency, and the CLI is installed from source. Rent itself is not fetched from or published to a package registry; the other dependencies in a generated project come from crates.io as usual.

Requirements

On macOS or Linux, install Rust with rustup:

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

source "$HOME/.cargo/env"

On Windows, download and run rustup-init.exe, then open a new terminal.

Verify the toolchain from the Rent repository root:

rustup --version
rustc --version
cargo --version

The workspace's rust-toolchain.toml automatically installs and selects the supported Rust compiler, Clippy, and rustfmt when you run a Rust command from this directory.

Install nextest before running application or workspace tests:

cargo install --locked cargo-nextest

cargo nextest --version

Install these additional tools when you need their workflows:

  • Docker with Compose runs PostgreSQL, MySQL, MariaDB, and extension test environments.
  • Node.js and pnpm run the documentation application.

Install the CLI

From the Rent repository root:

cargo install --locked --path crates/rent-cli

rent --version

Use --force when reinstalling the command after updating the checkout:

cargo install --locked --force --path crates/rent-cli

Create a new application

SQLite provides the smallest complete setup:

cd ..
rent new journal --database sqlite
cd journal

rent doctor
rent migrate dev --name initial
cargo check
cargo run

The scaffold writes an absolute path dependency to the local Rent crate and marks the application private. It also creates a starter entity, generated client, migration directories, rent.toml, formatter settings, and a runnable Tokio application.

For a server database, choose postgres, mysql, or mariadb:

rent new journal --database postgres
cd journal

docker compose up -d --wait

rent doctor
rent migrate dev --name initial
cargo run

The generated .env contains the local URL used by both the CLI and application. Commit .env.example, but keep .env out of version control.

Use Rent in an existing application

Add a path dependency and compile only the database the application deploys:

[dependencies]
rent = {
  path = "/absolute/path/to/rent/crates/rent",
  default-features = false,
  features = ["postgres"],
}

Backend features are postgres, mysql, and sqlite. MariaDB uses the mysql protocol and feature. Enable more than one only when the same binary genuinely connects to multiple database families.

Create the initial project files:

rent init User Post Comment
rent describe

rent init creates the declarations and immediately regenerates the typed client. Run rent generate after later manual schema edits.

An existing application also needs rent.toml. The conventional configuration is:

schema = "rent/schema.rsl"
generated = "src/generated"
migrations = "rent/migrations"

[database]
dialect = "postgres"
url_env = "DATABASE_URL"
backends = ["postgres"]

Keep credentials outside this file. Rent resolves the URL from --database-url, the environment variable named by url_env, or that variable in the project-root .env, in that order.

The generated client infers the backend from the URL:

let database_url = std::env::var("DATABASE_URL")?;

let client = generated::client::Client::connect(&database_url).await?;

Continue with choose a database for URLs, Cargo features, Docker development services, and deployment portability.

Update the checkout

Treat the Rent source revision and generated client as one reviewed dependency change:

  1. Update the local Rent checkout to the intended commit.
  2. Reinstall the CLI with cargo install --locked --force --path crates/rent-cli.
  3. Run rent generate in each application.
  4. Review the generated source and rent migrate diff output.
  5. Run the application's nextest and migration tests before deployment.

Do not hand-edit generated source to adapt an update. Schema changes belong in rent/schema.rsl; compatibility changes belong in application code or the Rent workspace.

Verify the installation

Run these checks from the application root:

rent doctor

rent migrate status

cargo nextest run

cargo nextest run expects the application to contain at least one test. A newly scaffolded application compiles and runs immediately, but its application-specific test suite is yours to define.

On this page