config-rs
config-rs copied to clipboard
Cannot override enum values (other than string) via enviornment variables
Hello, thanks for all the great work on this library. It appears that it's currently not possible to override specific enum variables/values other than string:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: invalid type: string "1", expected usize', src/main.rs:36:58
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Here's a repro of the problem: https://github.com/mbellani/config-error-repro. Apologies in advance if this is something that already works and i just don't know how to use it.
This issue is most certainly not only with enums, because I'm not certain whether config-rs actually handles if you pass a value for an integer field via ENV.
hello, i'm hitting this same problem as well when trying to use serde to get a struct out of the config; would you be open to a PR that attempts to determine the type of a Value on a best-effort basis inside the impl Source for Environment
So if you look at the tests in tests/legacy/env.rs
, there are examples of how it should work and AFAICS we're running these in CI, don't we? So it should work!
I am running into the same issue. I think the problem is that the tests enable .try_parsing()
, which isn't available in any released version of config
.
I think it would make sense to release a new version of config
.
0.12.0 was just released :partying_face: :tada: