From b49699175d55487529e29fe54d875ac5f883238a Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Sat, 6 Jun 2026 14:39:24 +0200 Subject: [PATCH] feat(server): load .env via dotenvy on startup The binary now reads a .env file itself (dotenvy::dotenv() at the top of main), so 'cargo run -p server' / the release binary pick up config without relying on just's 'set dotenv-load'. Missing .env is a no-op. Co-Authored-By: Claude Opus 4.8 (1M context) --- Cargo.lock | 1 + Cargo.toml | 1 + crates/server/Cargo.toml | 1 + crates/server/src/main.rs | 4 ++++ 4 files changed, 7 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 5eab7f0..ebb7995 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2077,6 +2077,7 @@ dependencies = [ "clap", "db", "domain", + "dotenvy", "http-body-util", "memory-serve", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index 3a86aa1..5fc4122 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,4 +28,5 @@ argon2 = "0.5" tower-sessions = "0.14" tower-sessions-sqlx-store = { version = "0.15", features = ["postgres"] } rpassword = "7" +dotenvy = "0.15" memory-serve = "2.1" diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index 2b75d6c..aab62c5 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -27,6 +27,7 @@ db = { path = "../db" } domain = { path = "../domain" } search = { path = "../search" } rpassword.workspace = true +dotenvy.workspace = true memory-serve = { workspace = true, optional = true } [build-dependencies] diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index 1894aa3..db1b576 100644 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs @@ -41,6 +41,10 @@ impl From for Role { #[tokio::main] async fn main() -> anyhow::Result<()> { + // Load a .env file (if present) so the binary picks up config when run directly, + // not only via `just` (which uses `set dotenv-load`). A missing .env is fine. + dotenvy::dotenv().ok(); + tracing_subscriber::fmt() .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) .init();