FuelLabs/fuels-rs · error
HOME env var missing
Error message
HOME env var missing
What it means
When FuelBinService (test helpers) is configured with DbType::RocksDb and no explicit database path, it defaults to $HOME/.fuel/db by reading the HOME environment variable. The expect panics when HOME is unset.
Source
Thrown at packages/fuels-test-helpers/src/fuel_bin_service.rs:49
"--ip".to_string(),
"127.0.0.1".to_string(),
"--port".to_string(),
"0".to_string(),
"--snapshot".to_string(),
self.snapshot_dir
.path()
.to_str()
.expect("Failed to find config file")
.to_string(),
];
args.push("--db-type".to_string());
match &self.node_config.database_type {
DbType::InMemory => args.push("in-memory".to_string()),
DbType::RocksDb(path_to_db) => {
args.push("rocks-db".to_string());
let path = path_to_db.as_ref().cloned().unwrap_or_else(|| {
PathBuf::from(std::env::var("HOME").expect("HOME env var missing"))
.join(".fuel/db")
});
args.push("--db-path".to_string());
args.push(path.to_string_lossy().to_string());
}
}
if let Some(cache_size) = self.node_config.max_database_cache_size {
args.push("--max-database-cache-size".to_string());
args.push(cache_size.to_string());
}
match self.node_config.block_production {
Trigger::Instant => {
args.push("--poa-instant=true".to_string());
}
Trigger::Never => {
args.push("--poa-instant=false".to_string());View on GitHub (pinned to d9a250a518)
Solutions
- Set HOME in the environment (ENV HOME=/root in Docker, export HOME=... in shell)
- Pass an explicit path instead: DbType::RocksDb(Some(PathBuf::from("./tmp-db"))) in the NodeConfig
- Run the tests from a normal user shell where HOME is defined
Example fix
// before
let mut node_config = NodeConfig::default();
node_config.database_type = DbType::RocksDb(None); // panics when HOME is unset
// after: explicit db path, no HOME dependency
let mut node_config = NodeConfig::default();
node_config.database_type = DbType::RocksDb(Some(std::path::PathBuf::from("/tmp/fuel-test-db"))); Defensive patterns
Strategy: validation
Validate before calling
// Guard before configuring a RocksDb-backed test node
if matches!(node_config.database_type, DbType::RocksDb(None)) {
assert!(
std::env::var("HOME").is_ok(),
"HOME must be set, or provide an explicit db path via DbType::RocksDb(Some(path))"
);
} Prevention
- Set HOME explicitly in Dockerfiles and CI environments that run the test suite
- Prefer DbType::RocksDb(Some(explicit_path)) so tests do not depend on the environment
- Use in-memory DB for tests that do not need persistence
When it happens
Trigger: Running tests that start a RocksDb-backed local node with node_config.database_type = DbType::RocksDb(None) inside an environment without HOME: minimal Docker containers, scrubbed CI shells, cron or systemd contexts.
Common situations: Docker scratch/distroless images; CI runners that clear the environment; headless agents running the test suite.
Related errors
- Error while trying to fetch wallets from the custom provider
- Failed to deploy the contract
- Failed to load the contract
- GITHUB_TOKEN is not set in the environment
AI-assisted analysis of FuelLabs/fuels-rs@d9a250a518 (2026-08-16).
Data as JSON: /api/errors/44e7ac5d3c2bcddd.
Report an issue: GitHub.