Databases 6 min read

How to Fix ClickHouse Rust Client Dependency Conflicts with Cargo Links

This article explains why using both clickhouse-rs (TCP) and clickhouse.rs (HTTP) in a single Rust project causes a Cargo links conflict, demonstrates failed workspace isolation attempts, and shows how renaming the links field in the native library resolves the issue.

JD Cloud Developers
JD Cloud Developers
JD Cloud Developers
How to Fix ClickHouse Rust Client Dependency Conflicts with Cargo Links

Problem Description

ClickHouse has two well‑maintained native Rust clients: clickhouse-rs (TCP) and clickhouse.rs (HTTP). Each works fine alone, but adding both to the same Cargo project triggers a build error.

Dependencies

# clickhouse http
clickhouse = { git = "https://github.com/loyd/clickhouse.rs", features = ["test-util"] }

# clickhouse tcp
clickhouse-rs = { git = "https://github.com/suharev7/clickhouse-rs", features = ["default"] }

Error Message

Blocking waiting for file lock on package cache
Updating git repository `https://github.com/suharev7/clickhouse-rs`
Updating crates.io index
error: failed to select a version for `clickhouse-rs-cityhash-sys`.
  ... required by package `clickhouse-rs v1.0.0-alpha.1`
  ... which satisfies git dependency `clickhouse-rs`
versions that meet the requirements `^0.1.2` are: 0.1.2

the package `clickhouse-rs-cityhash-sys` links to the native library `clickhouse-rs`, but it conflicts with a previous package which links to `clickhouse-rs` as well:
Only one package in the dependency graph may specify the same links value.
Try to adjust your dependencies so that only one package uses the links = 'clickhouse-rs-cityhash-sys' value.

Root Cause

The conflict originates from the clickhouse-rs-cityhash-sys crate, which is referenced differently by the two clients. clickhouse.rs pulls it from crates.io using a normal version entry, while clickhouse-rs includes it as a local path dependency.

# clickhouse.rs (crates.io)
clickhouse-rs-cityhash-sys = { version = "0.1.2", optional = true }
# clickhouse-rs (local)
[dependencies.clickhouse-rs-cityhash-sys]
path = "clickhouse-rs-cityhash-sys"
version = "0.1.2"

Attempted Workspace Isolation

Creating a Cargo workspace with separate libraries ( ck_http and ck_tcp) and moving each client into its own crate did not eliminate the conflict, because the links field is still duplicated in the dependency graph.

Solution

Inspecting clickhouse-rs-cityhash-sys/Cargo.toml reveals a links = "clickhouse-rs" entry. Changing this value to a unique name (e.g., links = "ck-rs-cityhash-sys") removes the duplication and the project builds successfully.

Understanding the links Field

The links field specifies the name of the native library that Cargo will link to. Only one package in the entire dependency graph may declare the same links name, ensuring a single copy of a native library in the final binary.

Conclusion

Renaming the links identifier in the conflicting native crate resolves the Cargo dependency conflict when using both ClickHouse Rust clients together. The full sample repository is available at https://github.com/jiashiwen/ck_dependency_conflict_sample for further experimentation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

RustclickhouseNative LibraryWorkspaceDependency Conflictcargo
JD Cloud Developers
Written by

JD Cloud Developers

JD Cloud Developers (Developer of JD Technology) is a JD Technology Group platform offering technical sharing and communication for AI, cloud computing, IoT and related developers. It publishes JD product technical information, industry content, and tech event news. Embrace technology and partner with developers to envision the future.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.