sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

SQLite is being selected as a feature when it shouldn't causing false `failed to select version for libsqlite3-sys` failure

Open matthewgapp opened this issue 2 years ago • 2 comments

Bug Description

Running into an error where cargo thinks that sqlx has the sqlite feature enabled when I don't. Looking at the Sqlx's Cargo.toml, enabling chrono, time, uuid shouldn't enable sqlx-sqlite but they do, according to cargo, causing a blocking error on our side. The only workaround at the moment is to fork sqlx and remove references to sqlite as we can't update the dependency in the sqlsync crate.

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"` (locked to 0.7.3) of package `sqlx v0.7.3`
    ... which satisfies dependency `sqlx = "^0.7.3"` (locked to 0.7.3) of package `rust-lang-issue-10801 v0.1.0 (/Users/matthewgapp/code/scratchpad/rust-lang-issue-10801)`
versions that meet the requirements `^0.27.0` (locked to 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.26.0 (https://github.com/trevyn/rusqlite?branch=wasm32-unknown-unknown#463090d3)`
    ... which satisfies git dependency `libsqlite3-sys` of package `sqlsync v0.2.0 (https://github.com/matthewgapp/sqlsync#c34cb11f)`
    ... which satisfies git dependency `sqlsync` of package `rust-lang-issue-10801 v0.1.0 (/Users/matthewgapp/code/scratchpad/rust-lang-issue-10801)`
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 ='libsqlite3-sys' 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

I also commented on an existing cargo bug that might be the root cause: https://github.com/rust-lang/cargo/issues/10801#issuecomment-1874741198. Would be great to know if perhaps it's a configuration issue on the SQLx side of things, though.

Minimal Reproduction

The offending cargo toml has these dependencies:

[dependencies]
sqlx = { version = "0.7.3", features = [ "runtime-tokio-rustls", "postgres", "chrono"], default-features = false }
sqlsync =  { git = "https://github.com/matthewgapp/sqlsync" }

Place into a new cargo project and run cargo build to see the error. Alternatively, you can clone this example repo: https://github.com/matthewgapp/rust-lang-issue-10801. You'll be able to reproduce the below error. Note that while the sqlsync crate does depend on sqlite the sqlx crate shouldn't depend on sqlite (note the weak references). But cargo thinks it does.

Info

  • SQLx version: 0.7.3
  • SQLx features enabled: ["runtime-tokio-rustls", "postgres", "chrono"]
  • Database server and version: N/A
  • Operating system: MacOS
  • rustc --version: 1.75

matthewgapp avatar Jan 03 '24 19:01 matthewgapp

Also running into this

joehoyle avatar Jan 23 '24 07:01 joehoyle

same here

tgruben avatar Feb 03 '24 16:02 tgruben

same

QAston avatar Mar 07 '24 19:03 QAston

I've run into this also, had to downgrade to: sqlx = { version = "=0.6.3", features = ["runtime-tokio-native-tls", "sqlite", "chrono"]} To make it run

palinko91 avatar Mar 13 '24 02:03 palinko91

This is unfortunately a Cargo bug as OP has found. Closing in favor of #3211 as an aggregation issue.

abonander avatar Apr 21 '24 01:04 abonander