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

Sqlx depend on libsqlite3-sys if sqlite feature is disabled #3556

Closed
LuckyTurtleDev opened this issue Oct 10, 2024 · 3 comments
Closed

Sqlx depend on libsqlite3-sys if sqlite feature is disabled #3556

LuckyTurtleDev opened this issue Oct 10, 2024 · 3 comments
Labels

Comments

@LuckyTurtleDev
Copy link

LuckyTurtleDev commented Oct 10, 2024

Bug Description

Sqlx depend on libsqlite3-sys if sqlite feature is disabled.

Minimal Reproduction

❯ mkdir sqlx-test
❯ cd sqlx-test
❯ cargo init

add the following dependecies to the Cargo.toml

matrix-sdk = { version = "0.7.1", default-features = false, features = ["native-tls", "e2e-encryption"], optional = true }
sqlx = { version = "0.8.2", optional = true, default-features = false, features = ["runtime-tokio", "migrate", "postgres", "macros"] }
❯ cargo run
    Updating crates.io index
error: failed to select a version for `libsqlite3-sys`.
    ... required by package `rusqlite v0.30.0`
    ... which satisfies dependency `rusqlite = "^0.30.0"` of package `matrix-sdk-sqlite v0.7.0`
    ... which satisfies dependency `matrix-sdk-sqlite = "^0.7.0"` of package `matrix-sdk v0.7.1`
    ... which satisfies dependency `matrix-sdk = "^0.7.1"` of package `sqlx-test v0.1.0 (/home/lukas/test/sqlx-test)`
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.2`
    ... which satisfies dependency `sqlx-sqlite = "=0.8.2"` of package `sqlx v0.8.2`
    ... which satisfies dependency `sqlx = "^0.8.2"` of package `sqlx-test v0.1.0 (/home/lukas/test/sqlx-test)`
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.

failed to select a version for `libsqlite3-sys` which could resolve this conflict

Additional Info

Looks like this only happen if the migrate is enabled.

Info

  • SQLx version: 0.8.2
  • SQLx features enabled: "runtime-tokio", "migrate", "postgres", "macros"
  • Database server and version: no idea. do not even get to this stepp
  • Operating system: Arch Linux
  • rustc --version: rustc 1.81.0 (eeb90cda1 2024-09-04)
@CommanderStorm
Copy link
Contributor

This is a bug in the way cargo resolves dependencys.
Please see #3211

The workaround would be to match up the libsqlite3-sys versions as suggested in the Cargo error.

@LuckyTurtleDev
Copy link
Author

thanks, for the fast feedback. sadly the other version is out of my control.

@abonander abonander closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2024
@LuckyTurtleDev
Copy link
Author

a small hack to workaround this issue is to use [patch.crates-io], to patch one libsqlite3-sys version to not use the c dependency anymore.

Cargo.toml:

[patch.crates-io]
libsqlite3-sys = { path = "./dummy-libsqlite3-sys" }

dummy-libsqlite3-sys/Cargo.toml:

[package]
name = "libsqlite3-sys"
version = "0.30.1"

[features]
default = []
bundled = []
pkg-config = []
unlock_notify = []
vcpkg = []

dummy-libsqlite3-sys/src/lib.rs:

//! Hack, due cargo bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants