rust-ctrlc icon indicating copy to clipboard operation
rust-ctrlc copied to clipboard

termination feature infects the entire workspace

Open nagisa opened this issue 3 years ago • 2 comments

Cargo will unify the features across crates, so if you have in your workspace two different crates that depend on ctrlc, one with termination feature enabled and other without, then the binary without it enabled will implicitly get the termination feature enabled for it as well, potentially leading to unintended behaviour.

nagisa avatar Nov 11 '20 16:11 nagisa

This is unfortunate. I don't know how to avoid this other than changing the handling of SIGTERM out from a feature and use a separate handler instead. Any ideas?

Detegr avatar Jan 08 '21 10:01 Detegr

Yeah, I don't believe you can get away by using a cargo feature here and will have to make users of this crate to indicate their preference through API in some shape or form.

nagisa avatar Jan 08 '21 12:01 nagisa

I think resolver = "2" in Cargo.toml fixes this issue nowadays.

Detegr avatar May 20 '23 18:05 Detegr

I think resolver = "2" in Cargo.toml fixes this issue nowadays.

I don't think that's the case. The new feature resolver avoids unifying features between dev-/build- deps and normal deps, but features are still unified within each type of dep. That is to say, if two crates in the normal dependency tree both depend on ctrlc (with compatible versions), and one sets termination, the same instance of ctrlc with termination enabled will be used by both.

jbg avatar Apr 18 '24 20:04 jbg