2

What is going on here:

From Cargo.toml:

name = "sitegen"
version = "0.2.0"
edition = "2021"

[dependencies]
axum_database_sessions = { version = "5.0", features = [ "mysql-native"] }
sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "mysql"] }
tokio = { version = "1.0", features = ["full"] }

Compile Error:

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/dsrich/.cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-rt-0.6.2/src/lib.rs:23:1
  |
23 | / compile_error!(
24 | |     "only one of ['runtime-actix-native-tls', 'runtime-async-std-native-tls', \
25 | |      'runtime-tokio-native-tls', 'runtime-actix-rustls', 'runtime-async-std-rustls', \
26 | |      'runtime-tokio-rustls'] can be enabled"
27 | | );
  | |_^

error: could not compile `sqlx-rt` due to previous error

I am using the latest rust x86-64 on linux, MySQL, and having rustls present in Cargo.toml or not makes no difference. Any suggestions? Just makes no sense to me...

Just trying to compile it to start using it with axum-sessions

Yuri Astrakhan
  • 8,808
  • 6
  • 63
  • 97

1 Answers1

1

The default features of axum_database_session is ["postgres-rustls"] therefore if you want to use *-native you have to disable default features:

axum_database_sessions = { version = "5.0", default-features = false, features = ["mysql-native"] }

but since you're explicitly including rustls in your dependency on sqlx you probably just want to use mysql-rustls instead, still without the default features because you're using MySQL instead of PostgreSQL:

axum_database_sessions = { version = "5.0", default-features = false, features = ["mysql-rustls"] }
cafce25
  • 15,907
  • 4
  • 25
  • 31
  • You're right, I've updated the answer with what you probably want instead `mysql-rustls` since you specified `runtime-tokio-rustls` on `sqlx` – cafce25 Dec 28 '22 at 17:38