rust-cli / confy

🛋 Zero-boilerplate configuration management in Rust
Other
912 stars 61 forks source link

Using features - fails if using ron_conf or yaml_conf #105

Open ghenry opened 5 days ago

ghenry commented 5 days ago

Hi,

If I set a feature to ron_conf or yaml_conf using:

confy = { version = "0.6.1", features = ["ron_conf"] }

I get:

error[E0428]: the name `EXTENSION` is defined multiple times
   --> /home/ghenry/.cargo/registry/src/index.crates.io-6f17d22bba15001f/confy-0.6.1/src/lib.rs:107:1
    |
101 | const EXTENSION: &str = "toml";
    | ------------------------------- previous definition of the value `EXTENSION` here
...
107 | const EXTENSION: &str = "ron";
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `EXTENSION` redefined here
    |
    = note: `EXTENSION` must be defined only once in the value namespace of this module

error: Exactly one config language feature must be enabled to compile confy.  Please disable one of either the `toml_conf`, `yaml_conf`, or `ron_conf` features. NOTE: `toml_conf` is a default feature, so disabling it might mean switching off default features for confy in your Cargo.toml
  --> /home/ghenry/.cargo/registry/src/index.crates.io-6f17d22bba15001f/confy-0.6.1/src/lib.rs:93:1
   |
93 | / compile_error!(
94 | |     "Exactly one config language feature must be enabled to compile \
95 | | confy.  Please disable one of either the `toml_conf`, `yaml_conf`, or `ron_conf` features. \
96 | | NOTE: `toml_conf` is a default feature, so disabling it might mean switching off \
97 | | default features for confy in your Cargo.toml"
98 | | );

Am I doing something wrong?

Thanks.

deg4uss3r commented 5 days ago

Hello @ghenry Looks like I need to make at least a docs update but it's erroring out here because we have toml set as the default feature on, and you have activated another feature to get this to compile today you'll need to update your Cargo.toml to:

[dependencies]
confy = { version = "0.6.1", default-features = false, features = ["ron_conf"] }

and it will compile fine with only ron support.

I'll investigate further to see if we can at least update the documentation/error handing here.

ghenry commented 5 days ago

Ah, thanks. I was reading the source to do a PR, but couldn't see the default one you've highlighted.

deg4uss3r commented 5 days ago

That's set here https://github.com/rust-cli/confy/blob/master/Cargo.toml#L21