nautechsystems/nautilus_trader · error · anyhow::Error
Gateway feature is not enabled. Build with --features gatewa
Error message
Gateway feature is not enabled. Build with --features gateway
What it means
DockerizedIBGateway's real Docker-backed implementation is behind the optional `gateway` cargo feature. Without it, a stub impl is compiled whose new() unconditionally bails, so any attempt to construct a dockerized gateway fails at runtime.
Source
Thrown at crates/adapters/interactive_brokers/src/gateway/dockerized.rs:554
}
}
Ok(())
}
}
/// Stub implementation when gateway feature is disabled.
#[cfg(not(feature = "gateway"))]
#[derive(Debug)]
pub struct DockerizedIBGateway;
#[cfg(not(feature = "gateway"))]
impl DockerizedIBGateway {
/// # Errors
///
/// Returns an error if the Dockerized IB Gateway cannot be created or started.
pub fn new(_config: crate::config::DockerizedIBGatewayConfig) -> anyhow::Result<Self> {
anyhow::bail!("Gateway feature is not enabled. Build with --features gateway")
}
}
#[cfg(all(test, feature = "gateway"))]
mod tests {
use rstest::rstest;
use super::DockerizedIBGateway;
use crate::config::TradingMode;
#[rstest]
#[case(TradingMode::Paper, 4002)]
#[case(TradingMode::Live, 4001)]
fn host_port_matches_trading_mode(#[case] trading_mode: TradingMode, #[case] expected: u16) {
assert_eq!(
DockerizedIBGateway::host_port_for_mode(trading_mode),
expected
);View on GitHub (pinned to 18893faf8b)
Solutions
- Rebuild with the feature enabled: cargo build --features gateway (or cargo test -p nautilus-interactive-brokers --features gateway) Add the feature to the dependency declaration: nautilus-adapters = { version = "...", features = ["gateway"] } or enable it via a workspace feature Gate your code with #[cfg(feature = "gateway")] so it compiles/fails clearly when the feature is absent
Example fix
// before cargo build -p nautilus-interactive-brokers // after cargo build -p nautilus-interactive-brokers --features gateway
Defensive patterns
Strategy: fallback
Validate before calling
#[cfg(not(feature = "gateway"))]
compile_error!("This binary requires the `gateway` feature"); Try / catch
match DockerizedIBGateway::new(config) {
Err(e) if e.to_string().contains("Gateway feature is not enabled") => {
anyhow::bail!("rebuild with --features gateway to use the dockerized gateway");
}
r => r,
} Prevention
- Enable the `gateway` feature in Cargo.toml for any binary that uses DockerizedIBGateway
- Add a CI build with --features gateway to catch feature omissions
- Document the required feature flag in your deployment/runbook
When it happens
Trigger: Calling DockerizedIBGateway::new(config) in a build compiled without --features gateway (the cfg(not(feature = "gateway")) stub at dockerized.rs:554).
Common situations: Running examples/binaries or tests with default features after writing code that uses the dockerized gateway; CI builds that omit the feature flag; forgetting the feature in Cargo.toml dependency declaration.
Related errors
- Failed to connect after {max_attempts} attempts
- Unknown IB security type: {value}
- Unknown IB option right: {value}
- Unknown IB historical tick type: {value}
- Unknown IB action: {value}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/2e3c1416d0ecc181.
Report an issue: GitHub.