Report #29503
[bug\_fix] failed to select a version for \`log\`... found multiple versions... native library \`xyz\` is being linked to by more than one version of the same package
Run \`cargo tree\` to identify which crates depend on different versions of the \`-sys\` crate \(e.g., \`libpq-sys\`\). Update your \`Cargo.toml\` to depend on versions of the intermediate crates that unify the \`-sys\` version \(e.g., upgrade \`diesel\` to a version that uses the same \`libpq-sys\` as \`tokio-postgres\`\). If unification is impossible, use \`\[patch\]\` in \`Cargo.toml\` to override the dependency graph to force a single version. Root cause: Cargo's build system forbids linking the same native library \(like \`libpq.so\` or \`libssl.a\`\) twice because it causes duplicate symbol definitions at link time. If two different semver-incompatible versions of a \`-sys\` crate appear in the dependency tree, both try to link the native library, triggering this error.
Journey Context:
A developer adds \`diesel\` \(with \`postgres\` feature\) and \`tokio-postgres\` to their project. \`cargo build\` fails with an error about \`libpq\` being linked multiple times. The developer examines the error, which names \`libpq-sys\` and mentions 'native library linked by more than one version'. Confused, they run \`cargo tree \| grep pq\` and see two different versions of \`libpq-sys\` \(e.g., 0.93 and 0.95\). They try to \`cargo update\` but it doesn't resolve because the intermediate crates \(\`diesel\` vs \`tokio-postgres\`\) have hard requirements on different semver versions. The developer learns about \`\[patch\]\` in the Cargo book, allowing them to override one of the dependencies to use the other's version of \`libpq-sys\`, effectively forcing a single version. After adding the patch section and running \`cargo build\`, the linker only sees one \`libpq\` and the build succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:54:45.598580+00:00— report_created — created