clickhouse.rs icon indicating copy to clipboard operation
clickhouse.rs copied to clipboard

Unable to compile versions 0.11.3 and later

Open jeffw-wherethebitsroam opened this issue 2 years ago • 3 comments

Hi,

I tried today to update a project using clickhouse.rs. It was previously using v0.10.

The error for v0.11.6 is shown below, but I got the same error for v0.11.3-6. v0.11.0-2 compilied fine.

I'm using rustc 1.72.1 on an intel mac.

   Compiling clickhouse v0.11.6
error[E0277]: the trait bound `Vec<u8>: From<bytes::Bytes>` is not satisfied
  --> /Users/jeffwilliams/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clickhouse-0.11.6/src/response.rs:92:42
   |
92 |     let reason = String::from_utf8(bytes.into())
   |                                          ^^^^ the trait `From<bytes::Bytes>` is not implemented for `Vec<u8>`
   |
   = help: the following other types implement trait `From<T>`:
             <Vec<u8> as From<CString>>
             <Vec<u8> as From<std::string::String>>
             <Vec<u8> as From<&str>>
   = note: required for `bytes::Bytes` to implement `Into<Vec<u8>>`

error: future cannot be sent between threads safely
  --> /Users/jeffwilliams/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clickhouse-0.11.6/src/response.rs:30:23
   |
30 |           Self::Waiting(Box::pin(async move {
   |  _______________________^
31 | |             let response = response.await?;
32 | |             let status = response.status();
33 | |             let body = response.into_body();
...  |
39 | |             }
40 | |         }))
   | |__________^ future created by async block is not `Send`
   |
note: opaque type is declared here
  --> /Users/jeffwilliams/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clickhouse-0.11.6/src/response.rs:71:92
   |
71 | async fn collect_bad_response(status: StatusCode, body: Body, compression: Compression) -> Error {
   |                                                                                            ^^^^^
note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
  --> /Users/jeffwilliams/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clickhouse-0.11.6/src/response.rs:28:19
   |
28 |     pub(crate) fn new(response: ResponseFuture, compression: Compression) -> Self {
   |                   ^^^
note: future is not `Send` as it awaits another future which is not `Send`
  --> /Users/jeffwilliams/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clickhouse-0.11.6/src/response.rs:38:21
   |
38 |                 Err(collect_bad_response(status, body, compression).await)
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl futures::Future<Output = error::Error>`, which is not `Send`
   = note: required for the cast from `Pin<Box<[async block@/Users/jeffwilliams/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clickhouse-0.11.6/src/response.rs:30:32: 40:10]>>` to `Pin<Box<(dyn futures::Future<Output = std::result::Result<response::Chunks<Body>, error::Error>> + std::marker::Send + 'static)>>`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `clickhouse` (lib) due to 2 previous errors

My projects dependencies are:

clickhouse = { version = "0.11.6" }
csv = "1.2"
serde = { version = "1", features = ["derive"] }
flate2 = "1.0"
tokio = { version = "1", features = ["full"] }
time = { version = "0.3.29", features = [
    "formatting",
    "parsing",
    "serde",
    "macros",
] }
log = "0.4.20"
env_logger = "0.10.0"

jeffw-wherethebitsroam avatar Sep 29 '23 09:09 jeffw-wherethebitsroam

Interesting, I cannot reproduce it locally for now.

loyd avatar Oct 05 '23 18:10 loyd

Which code do you use when facing it?

loyd avatar Oct 05 '23 18:10 loyd

I was trying to make a minimal reproduction of this in a new app. But couldn't.

I ended up running cargo update on the whole original project, which resolved the issue.

I then restored the orginal Cargo.lock and did some individual package updates and this one seems to be the required fix:

% cargo update -p bytes
    Updating crates.io index
    Updating bytes v1.1.0 -> v1.5.0

So you might need to update the dependency on bytes.

jeffw-wherethebitsroam avatar Oct 09 '23 13:10 jeffw-wherethebitsroam