shuttle-hq / shuttle-examples

Examples for using Shuttle with different frameworks and resources
https://www.shuttle.rs
147 stars 59 forks source link

Using PostgreSQL for Axum, with the latest sqlx 8.0 error #183

Open DK26 opened 3 months ago

DK26 commented 3 months ago

Hi,

A new sqlx crate is out, and upgrading would cause the example to error with conflicts:

error: failed to select a version for `libsqlite3-sys`.
    ... required by package `sqlx-sqlite v0.7.1`
    ... which satisfies dependency `sqlx-sqlite = "=0.7.1"` of package `sqlx v0.7.1`
    ... which satisfies dependency `sqlx = "^0.7.1"` of package `shuttle-shared-db v0.47.0`
    ... which satisfies dependency `shuttle-shared-db = ">=0.47"` of package `test-postgresql v0.1.0 (/home/test/test-postgresql)`   
versions that meet the requirements `^0.26.0` are: 0.26.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.28.0`
    ... which satisfies dependency `libsqlite3-sys = "^0.28.0"` of package `sqlx-sqlite v0.8.0`
    ... which satisfies dependency `sqlx-sqlite = "=0.8.0"` of package `sqlx v0.8.0`
    ... which satisfies dependency `sqlx = "^0.8.0"` of package `test-postgresql v0.1.0 (/home/test/test-postgresql)`
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

Playing around with it, disabling default features and specifying, did not solve the problem, which by this point has overwhelmed me.

Cargo.toml

[package]
name = "test-postgresql"
version = "0.1.0"
edition = "2021"

[dependencies]
axum = ">=0.7"
shuttle-axum = ">=0.47"
shuttle-runtime = ">=0.47"
shuttle-shared-db = {version = ">=0.47", features = ["postgres", "sqlx"] }
tokio = ">=1.39"
sqlx = ">=0.8"
joshua-mo-143 commented 2 months ago

Hi!

This issue will be resolved once the new version of shuttle-shared-db is released. A change has already been merged but we're waiting for the new release.

In the meantime, the latest supported SQLx version is 0.7.1.