-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional dependency is not omitted at package building. #10604
Comments
The challenge here comes from two parts
Is there a reason you are declaring feature flags per semver-compatible version? I normally see something like this for semver-incompatible versions. Independent of the error, there are also challenges with #2980 |
Thank you for the response @epage. It's a specific situation. I can create separate package versions for different dependency versions. However, there is almost no difference between these packages (they only differ in dependencies and a couple of lines of code). Then by adding new features, I will have to support both versions (building, releases, etc.). Using features was more convenient for me, but I see your point and these challenges. So for now, I will create and support separate package versions. |
Is |
Unfortunately, not in that case. We are using it to modify the Solana test program - to make it easier to use for us. It's touching Solana internals that is working differently in 1.9 and 1.10. |
I have this exact issue with parity-scale-codec. I can, for sure deploy two separate binaries but at the moment we are not publishing packages. Otherwise I have the same approach here https://github.com/TrueLayer/reqwest-middleware/blob/main/reqwest-tracing/src/otel.rs |
I'm going to close as this is working as intended. Cargo's resolution is designed to prevent two edges to two different semver-compatible versions of the same package. I don't think this will be relaxed or changed in the foreseeable future. |
Problem
I'm building a library that needs to work with two versions of dependencies:
The user should decide which version he likes to use based on provided features flag. I have the following
Cargo.toml
file:I expected that building it with just
cargo build
should work, and it will build it with1.10
version (as it's marked as default). However, it does not work.I also tried different combinations like:
cargo build --features solana_1_9 --no-default-features
cargo build --features solana_1_10 --no-default-features
None of these commands works. Command output suggests version collisions:
Also it's working perfectly fine when I declare it as external dependency in other project like:
cargo-bug-poc = { version = "0.1.0", default-features = false, features=["solana_1_9"], path = "../cargo-bug-poc" }
.Steps
I created a repo to test this potential bug: link
lib
folder (with default-features and features flags) and expect an error.prog
with differentfeatures
as dependency flags and see that it's working.Possible Solution(s)
No response
Notes
No response
Version
The text was updated successfully, but these errors were encountered: