Conditionally enabling a dependency feature for a specific OS

Having some trouble with enabling a specific feature only for a Linux build

The feature is defined here and used here

I tried to explicitly enable it for Linux and not for windows via

[target.'cfg(target_os = "windows")'.dependencies]
tray-item = { version = "0.8.0" }

[target.'cfg(target_os = "linux")'.dependencies]
tray-item = { version = "0.8.0", features = ["ksni"] }

But it still tries to compile it (and thus libdbus-sys that errors out) when on windows

Removing the Linux bit altogether causes a successful build

Could you try doing feature resolution with Cargo's new resolver by adding this to your Cargo.toml file:

resolver = "2"

and see if that fixes your issue?

Added it at the workspace level, seems to work!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.