From a3065ed39f871e251d2e3762219c78859cb51f06 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 28 Dec 2019 12:11:06 +0100 Subject: [PATCH] Fix overriding config vars with underscore from environment --- README.md | 2 +- server/src/settings.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fa35788d..143bfaa7 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,7 @@ into your local `config.hjson` file. Additionally, you can override any config files with environment variables. These have the same name as the config options, and are prefixed with `LEMMY_`. For example, you can override the `database.password` with -`LEMMY_DATABASE_PASSWORD=my_password`. +`LEMMY__DATABASE__POOL_SIZE=10`. An additional option `LEMMY_DATABASE_URL` is available, which can be used with a PostgreSQL connection string like `postgres://lemmy:password@lemmy_db:5432/lemmy`, passing all connection details at once. diff --git a/server/src/settings.rs b/server/src/settings.rs index 7da19c0f..446bf04f 100644 --- a/server/src/settings.rs +++ b/server/src/settings.rs @@ -70,7 +70,10 @@ impl Settings { // Add in settings from the environment (with a prefix of LEMMY) // Eg.. `LEMMY_DEBUG=1 ./target/app` would set the `debug` key - s.merge(Environment::with_prefix("LEMMY").separator("_"))?; + // Note: we need to use double underscore here, because otherwise variables containing + // underscore cant be set from environmnet. + // https://github.com/mehcode/config-rs/issues/73 + s.merge(Environment::with_prefix("LEMMY").separator("__"))?; return s.try_into(); } -- 2.44.1