After updating my dependencies the config loader stopped working.
pub fn init_config<'de, T: Deserialize<'de>>() -> Result<T, ConfigError> {
let env = std::env::var("RUN_MODE").unwrap_or_else(|_| "default".into());
info!("Using settings from: {}", env);
::config::Config::builder()
.add_source(File::with_name(&format!("config/{env}")).required(true))
// Add in a local configuration file
// This file shouldn't be checked in to git
// s.merge(File::with_name("config/local").required(false))?;
// Add in settings from the environment (with a prefix of APP)
// Eg.. `APP_DEBUG=1 ./target/app` would set the `debug` key
.add_source(
Environment::with_prefix("APP")
.separator("__")
.prefix_separator("_")
.try_parsing(true),
)
// You may also programmatically change settings
// s.set("database.url", "postgres://")?;
// Now that we're done, let's access our configuration
// println!("debug: {:?}", s.get_bool("debug"));
// You can deserialize (and thus freeze) the entire configuration as
.build()?
.try_deserialize()
}
After updating my dependencies the config loader stopped working.
RUN_MODE=local cargo run --release