错误 运行 带有 clickhouse 依赖项的 cargo build

Error running cargo build with clickhouse dependency

我按照说明将其添加到我的 cargo toml 文件中 here

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

但是当我 运行 cargo build 我得到一个失败消息:

   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

我对 Rust 很陌生,所以我不知道该做什么,有什么想法吗?

如果相关的话,我运行正在使用 MacOS BigSur。

我也在 Linux 上收到此错误。这似乎是 clickhouse crate 中的一个问题,但它可以在您的 Cargo.toml 中修复。 #[tokio::test] 指的是 macro,它同时需要“rt”和“macros”功能,但 clickhouse crate 中的 Cargo.toml 文件只包含“rt”功能。为了添加此功能以便 crate 可以编译,您可以在 Cargo.toml for tokio 中添加一行以启用该功能:

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

添加这一行为我修复了编译器错误。

我注意到还有另一个 clickhouse 箱子,它可能也有帮助