gudjonragnar
gudjonragnar

Reputation: 35

Error running cargo build with clickhouse dependency

I added this to my cargo toml file, following the instructions here

[dependencies]
clickhouse = "0.6.3"
reflection = "0.1.3"

but when I run cargo build I get a failure saying:

   Compiling clickhouse v0.6.3
error[E0433]: failed to resolve: could not find `test` in `tokio`
   --> /Users/gudjonragnar/.cargo/registry/src/github.com-1ecc6299db9ec823/clickhouse-0.6.3/src/compression/lz4.rs:163:10
    |
163 | #[tokio::test]
    |          ^^^^ could not find `test` in `tokio`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.
error: could not compile `clickhouse`

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

I am quite new to Rust so I don't know what to do here, any thoughts?

I am running on MacOS BigSur if that is relevant.

Upvotes: 0

Views: 595

Answers (1)

transistor
transistor

Reputation: 1660

I am getting this error on Linux as well. This appears to be an issue in the clickhouse crate, but it can be fixed in your Cargo.toml. #[tokio::test] refers to a macro which requires both the "rt" and "macros" features, but the Cargo.toml file in the clickhouse crate only includes the "rt" feature. In order to add this feature so that the crate will compile, you can add a line to your Cargo.toml for tokio that enables that feature:

tokio = { version = "1.0.1", features = ["rt", "macros"] }

Adding this line fixed the compiler error for me.

I noticed there is another clickhouse crate, which might also be helpful

Upvotes: 1

Related Questions