Skip to content
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

Native dependency conflicts even if the native dependency is not active due to disabled features #14462

Closed
hkratz opened this issue Aug 28, 2024 · 1 comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@hkratz
Copy link
Contributor

hkratz commented Aug 28, 2024

Problem

This is similar to #7880 but even worse, because the native libraries should never be in the dependency graph at all as they are only selected for optional features, which are not enabled. In the example below with no default features and sqlite not in the feature list the sqlite native library is not part of either binary but still causes a conflict.

Steps

Workspace Cargo.toml

[workspace]
members = ["bin1", "bin2"]
resolver = "2"

bin1 Cargo toml

[package]
name = "bin1"
version = "0.1.0"
edition = "2021"

[dependencies]
sqlx = { version = "0.8.1", features = ["time"], default-features = false }

bin2 Cargo.toml

[package]
name = "bin2"
version = "0.1.0"
edition = "2021"

[dependencies]
sqlx = { version = "0.7.3", features = ["time"], default-features = false }

This causes:

error: failed to select a version for `libsqlite3-sys`.
    ... required by package `sqlx-sqlite v0.7.3`
    ... which satisfies dependency `sqlx-sqlite = "=0.7.3"` of package `sqlx v0.7.3`
    ... which satisfies dependency `sqlx = "^0.7.3"` of package `bin2 v0.1.0 (/Users/hans/dev/spikes/sqlx-sqlite-test/bin2)`
versions that meet the requirements `^0.27.0` are: 0.27.0

the package `libsqlite3-sys` links to the native library `sqlite3`, but it conflicts with a previous package which links to `sqlite3` as well:
package `libsqlite3-sys v0.30.1`
    ... which satisfies dependency `libsqlite3-sys = "^0.30.1"` of package `sqlx-sqlite v0.8.1`
    ... which satisfies dependency `sqlx-sqlite = "=0.8.1"` of package `sqlx v0.8.1`
    ... which satisfies dependency `sqlx = "^0.8.1"` of package `bin1 v0.1.0 (/Users/hans/dev/spikes/sqlx-sqlite-test/bin1)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the `links = "sqlite3"` value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

Please note that at least one (non-sqlite) feature has to be selected for sqlx otherwise the bug does not occur.

Version

cargo 1.82.0-nightly (8f40fc5 2024-08-21)

@hkratz hkratz added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Aug 28, 2024
@hkratz
Copy link
Contributor Author

hkratz commented Aug 28, 2024

This is apparently a known issue, see launchbadge/sqlx#3211

@hkratz hkratz closed this as completed Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants
@hkratz and others