transact-rs/sqlx · critical
one of the `runtime` features of SQLx must be enabled
Error message
one of the `runtime` features of SQLx must be enabled
What it means
The second branch of missing_rt() in sqlx-core/src/rt/mod.rs: panics when NO sqlx `runtime` feature is enabled at compile time (`cfg!(feature = "_rt-tokio")` is false). sqlx's runtime-independent API needs at least one `runtime-*` feature to select the async executor implementation; without it, any API that touches the runtime abstraction cannot work.
Source
Thrown at sqlx-core/src/rt/mod.rs:169
} else if #[cfg(feature = "_rt-tokio")] {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("failed to start Tokio runtime")
.block_on(f)
} else {
missing_rt(f)
}
}
}
#[track_caller]
pub const fn missing_rt<T>(_unused: T) -> ! {
if cfg!(feature = "_rt-tokio") {
panic!("this functionality requires a Tokio context")
}
panic!("one of the `runtime` features of SQLx must be enabled")
}
impl<T: Send + 'static> Future for JoinHandle<T> {
type Output = T;
#[track_caller]
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match &mut *self {
#[cfg(feature = "_rt-async-std")]
Self::AsyncStd(handle) => Pin::new(handle).poll(cx),
#[cfg(feature = "_rt-async-task")]
Self::AsyncTask(task) => Pin::new(task)
.as_pin_mut()
.expect("BUG: task taken")
.poll(cx),
#[cfg(feature = "_rt-tokio")]View on GitHub (pinned to 03af8bcc57)
Solutions
- Add a runtime feature: `sqlx = { features = ["runtime-tokio", "postgres"] }` (or `-rustls`/`-native-tls` variants).
- Search the workspace for `default-features = false` on the sqlx dependency and ensure at least one member enables a runtime feature.
- Run `cargo tree -i sqlx` and `cargo tree -e features` to confirm which feature set is actually compiled in.
Example fix
// before (Cargo.toml)
sqlx = { version = "0.8", features = ["postgres"], default-features = false }
// after
sqlx = { version = "0.8", features = ["runtime-tokio", "postgres"], default-features = false } Defensive patterns
Strategy: validation
Validate before calling
// Cargo.toml — fail compilation if no runtime feature:
[features]
default = ["runtime-tokio"]
// or in code:
#[cfg(not(any(feature = "runtime-tokio")))]
compile_error!("sqlx requires a runtime-* feature"); Prevention
- Never specify sqlx with default-features = false without adding a runtime feature
- Pin the sqlx feature set in a single workspace-level dependency
- Verify features with `cargo tree -e features -i sqlx` in CI
When it happens
Trigger: Using sqlx with Cargo.toml features that omit any `runtime-*` feature, e.g. `features = ["postgres"]` only, or `default-features = true` lost via a dependency that re-specifies sqlx without runtime features. Any pool/connect/query call then panics at first use.
Common situations: Feature unification surprises: a workspace member enables sqlx with `default-features = false` and no runtime feature; copying a minimal Cargo.toml snippet; upgrading to sqlx 0.7+ where `runtime-async-std` etc. were removed/renamed.
Related errors
- one of the `runtime-*-native-tls` or `runtime-*-rustls` feat
- No drivers installed. Please see the documentation in `sqlx:
- this functionality requires a Tokio context
- Cannot use both flatten and json
- Cannot use both try from and json nullable
AI-assisted analysis of transact-rs/sqlx@03af8bcc57 (2026-09-03).
Data as JSON: /api/errors/7f8124a92e585507.
Report an issue: GitHub.