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

Adding sqlx-adapter to the project breaks compilation #59

Closed
mkpankov opened this issue Jun 9, 2021 · 2 comments
Closed

Adding sqlx-adapter to the project breaks compilation #59

mkpankov opened this issue Jun 9, 2021 · 2 comments
Assignees
Labels
invalid This doesn't seem right

Comments

@mkpankov
Copy link

mkpankov commented Jun 9, 2021

I have a workspace project. In one of the sub-projects, I'm already using sqlx and tokio:

casbin = "2.0.2"
sqlx = {version = "0.5", features = ["json", "offline", "postgres", "runtime-tokio-rustls", "chrono"]}
tokio = {version = "1", features = ["macros", "rt-multi-thread"]}
...

I then add sqlx-adapter to Cargo.toml:

casbin = "2.0.2"
sqlx = {version = "0.5", features = ["json", "offline", "postgres", "runtime-tokio-rustls", "chrono"]}
tokio = {version = "1", features = ["macros", "rt-multi-thread"]}
sqlx-adapter = { version = "0.4.1", features = ["postgres"] }

And try to compile:

➜  git:(master) ✗ cargo check
   Compiling sqlx-rt v0.5.5
    Checking casbin v2.0.7
error: only one of ['runtime-actix-native-tls', 'runtime-async-std-native-tls', 'runtime-tokio-native-tls', 'runtime-actix-rustls', 'runtime-async-std-rustls', 'runtime-tokio-rustls'] can be enabled
  --> /home/mkpankov/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-rt-0.5.5/src/lib.rs:21:1
   |
21 | / compile_error!(
22 | |     "only one of ['runtime-actix-native-tls', 'runtime-async-std-native-tls', \
23 | |      'runtime-tokio-native-tls', 'runtime-actix-rustls', 'runtime-async-std-rustls', \
24 | |      'runtime-tokio-rustls'] can be enabled"
25 | | );
   | |__^

error: aborting due to previous error

error: could not compile `sqlx-rt`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...

There's following diff in the Cargo.lock:

diff --git a/Cargo.lock b/Cargo.lock
index 9e1602cd6..c7ec331f4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -495,6 +495,7 @@ dependencies = [
  "rhai",
  "serde 1.0.126",
  "thiserror",
+ "tokio",
 ]

 [[package]]
@@ -1153,6 +1154,7 @@ dependencies = [
  "serde_json",
  "serde_yaml",
  "sqlx",
+ "sqlx-adapter",
  "thiserror",
  "tokio",
  "tokio-runtime-panic-fix",
@@ -4228,6 +4230,18 @@ dependencies = [
  "sqlx-macros",
 ]

+[[package]]
+name = "sqlx-adapter"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32bd18442e437cf667268f0b3f0b73519342d25a5a87c0d6e518ba0541f26528"
+dependencies = [
+ "async-trait",
+ "casbin",
+ "dotenv",
+ "sqlx",
+]
+
 [[package]]
 name = "sqlx-core"
 version = "0.5.5"
@@ -4309,8 +4323,10 @@ version = "0.5.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8199b421ecf3493ee9ef3e7bc90c904844cfb2ea7ea2f57347a93f52bfd3e057"
 dependencies = [
+ "native-tls",
  "once_cell",
  "tokio",
+ "tokio-native-tls",
  "tokio-rustls",
 ]

It looks like there are hardcoded sqlx features in the sqlx-adapter that collide with features I'm using.

@mkpankov
Copy link
Author

Incorrect features were selected

@hsluoyz hsluoyz self-assigned this Jun 10, 2021
@hsluoyz hsluoyz added the invalid This doesn't seem right label Jun 10, 2021
@kvzn
Copy link

kvzn commented Oct 27, 2021

Using sqlx-adapter = { version = "0.4.2", default-features = false, features = ["postgres", "runtime-tokio-rustls"] } fixed my issue, the key point is default-features = false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants