You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
buildRustPackage: found duplicate version of package #30742
I wanted to upgrade rustup to 1.6 now that we have a recent rust compiler again thanks to #30088.
Unfortunately I got an error, the log tail is below.
Rustup uses a [replace] section for mio in its Cargo.toml, so that is probably the cause for the error.
The error output itself is from cargo-vendor. I would report it there but I'm not sure why it can't handle this, maybe there is some good reason and we should use it in a different way.
There shouldn't be any trouble to reproduce this, updating the hash and version for the rustup derivation
should do.
I suspect this is a general problem with cargo packages that use [replace], hence the issue name.
$ nix-build '<nixpkgs-work>' -A rustup --no-out-link
...
Downloading aho-corasick v0.5.3
Downloading lzma-sys v0.1.8
Downloading foreign-types v0.2.0
Downloading gcc v0.3.53
error: failed to sync
Caused by:
found duplicate version of package `mio v0.6.10` vendored from two sources:
source 1: https://github.com/carllerche/mio#6871f83a
source 2: registry https://github.com/rust-lang/crates.io-index
builder for ‘/nix/store/ycmixz6k8djya309dl67x4px97qr595c-rustup-1.6.0-vendor.drv’ failed with exit code 101
cannot build derivation ‘/nix/store/sq4ci1azfqg1jnmsj6zdjcjaj89cdbjk-rustup-1.6.0.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/sq4ci1azfqg1jnmsj6zdjcjaj89cdbjk-rustup-1.6.0.drv’ failed
Reacted by Aaron Janse, Ruud van Asseldonk, junji hashimoto, Kirin Etheridge and Phani Rithvij
I did the packaging but actually don't have much insight on how the internals are working. The cargo-vendor author might be able to tell us why the [replace] directive is not overriding the crates.io entry.
Hey I have run into this issue trying to build a package for "spotifyd".
I get duplicate versions of 'rust-crypto', which is the only [replace] directive in the project.
FTR, cargo-vendor has a flag (--no-merge-sources) now which solves the root problem. If buildRustPackage gets adapted, crates like spotifyd should work.
I was also working on a package for spotifyd (see #47172), but just like @BadDecisionsAlex I ran into this issue. @ljli I couldn't find the no-merge-sources in cargo-vendor. I tried adding --no-merge-sources to the cargoBuildFlags, but that still resulted in the same error. Any ideas?
Also, I was able to build spotifyd inside nix-shell:
The flag --no-merge-sources is available in the current cargo-vendor master branch. So first of all we need to update it in nixpkgs.
The place to pass the flag would then be here:
I think something along those lines should work, it is based on staging because of #46362.
Unfortunately I hit the following now:
$ nix build nixpkgs-work.spotifyd
error: path '/nix/store/kyvsqxp7cz3f0dhf1l7ly1vw9208wn88-spotifyd-0.2.2-vendor' is not valid
I have no clue why, maybe this is a local problem so you are welcome to try the branch and/or pick it up from there, otherwise I'll investigate after staging got merged.
(...)
Downloaded winapi-i686-pc-windows-gnu v0.4.0
error: failed to sync
Caused by:
found duplicate version of package `parking_lot v0.9.0` vendored from two sources:
source 1: https://github.com/terminal-discord/parking_lot?rev=046a171#046a1714
source 2: registry `https://github.com/rust-lang/crates.io-index`
Traceback (most recent call last):
File "/nix/store/14qgqb8avba5fbpsdwmnys49h2k8ljmk-cargo-vendor-normalise/bin/.cargo-vendor-normalise-wrapped", line 42, in <module>
main()
File "/nix/store/14qgqb8avba5fbpsdwmnys49h2k8ljmk-cargo-vendor-normalise/bin/.cargo-vendor-normalise-wrapped", line 17, in main
assert list(data.keys()) == ["source"]
AssertionError
builder for '/nix/store/ccwiz2jm9kvfgc9qk3gddxpy7m6c1par-weechat-discord-beta-vendor.drv' failed with exit code 1
cannot build derivation '/nix/store/gg7fwmp6yr5xh83w4idxla65nxa2ccqp-weechat-discord-beta.drv': 1 dependencies couldn't be built
error: build of '/nix/store/gg7fwmp6yr5xh83w4idxla65nxa2ccqp-weechat-discord-beta.drv' failed
I ran into the same error while building a project with a direct dependency that is also a dependency of another direct dependency but from a different source. The resulting Cargo.lock then lists both source separately:
Can we get rid of broken cargo vendor for the purpose of buildRustPackage?
We could reconstruct repository at $HOME/.cargo instead of ./vendor directory (akin to $HOME/.m2 is reconstructed for java projects, which lack any maven vendor).
Using cargo vendor has another issue: it tries to build every package under ./vendor/, even those which are not suppose to built.
For example, if you package TiKV, even after working around 3 duplicates, you'll hit at build failure of ./vendor/libtitan_sys-0.0.1 - the package which should not be built as an independent package at all.
I ran into this issue when trying to wgsl-analyzer. In their ide package, they use multiple versions of the naga library on purpose. Working around the issue seems to require patching a substantial amount of Rust code (to drop support for all versions of naga except for one), which is not sustainable and results in lost of functionality.
With the cancellation of rust-lang/cargo#10344 due to potential syntactic conflict with another Rust RFC, the problem is unlikely to be solved upstream soon. I support @kvtb's idea of migrating away from cargo vendor for buildRustPackage.
Reacted by Campbell Cole, Fea, arijoon, Kirin Etheridge, junji hashimoto, Hans Christian Schmitz, musjj and Tristan Schrader
Activity
wizeman commentedon Oct 25, 2017
cc @zimbatm
zimbatm commentedon Oct 26, 2017
I did the packaging but actually don't have much insight on how the internals are working. The cargo-vendor author might be able to tell us why the [replace] directive is not overriding the crates.io entry.
alex-ameen commentedon Aug 11, 2018
Hey I have run into this issue trying to build a package for "spotifyd".
I get duplicate versions of 'rust-crypto', which is the only [replace] directive in the project.
Did you ever find a solution?
ljli commentedon Sep 6, 2018
FTR, cargo-vendor has a flag (
--no-merge-sources) now which solves the root problem. IfbuildRustPackagegets adapted, crates like spotifyd should work.bobvanderlinden commentedon Sep 22, 2018
I was also working on a package for spotifyd (see #47172), but just like @BadDecisionsAlex I ran into this issue. @ljli I couldn't find the
no-merge-sourcesincargo-vendor. I tried adding--no-merge-sourcesto thecargoBuildFlags, but that still resulted in the same error. Any ideas?Also, I was able to build spotifyd inside nix-shell:
ljli commentedon Sep 23, 2018
The flag
--no-merge-sourcesis available in the currentcargo-vendormaster branch. So first of all we need to update it in nixpkgs.The place to pass the flag would then be here:
nixpkgs/pkgs/build-support/rust/fetchcargo.nix
Line 45 in fcde178
I'll try to have a look tomorrow.
ljli commentedon Sep 23, 2018
My first attempt to hook up
--no-merge-sourcesis here:https://github.com/ljli/nixpkgs/tree/cargo-vendor-multi-sources
I think something along those lines should work, it is based on staging because of #46362.
Unfortunately I hit the following now:
I have no clue why, maybe this is a local problem so you are welcome to try the branch and/or pick it up from there, otherwise I'll investigate after staging got merged.
boomshroom commentedon Oct 8, 2018
Could you perhaps submit a pull request for that? I'm running into the same problem.
zimbatm commentedon Sep 13, 2019
A bunch of things have changed on the rust packaging side which probably fix this issue. Ping me if I should re-open.
bqv commentedon Feb 18, 2020
@zimbatm I think this issue is still quite relevant. See:
Which for me, fails with:
zimbatm commentedon Feb 18, 2020
On what version of nixpkgs did you experience the issue?
What are the instructions to reproduce this error independently?
bqv commentedon Feb 18, 2020
Unstable and/or master, and simply trying to build that expression suffices to create that error.
Here is it wrapped in a shell script for your convenience:
https://termbin.com/fo72
FlorianFranzen commentedon Mar 19, 2020
I ran into the same error while building a project with a direct dependency that is also a dependency of another direct dependency but from a different source. The resulting
Cargo.lockthen lists both source separately:https://github.com/paritytech/polkadot/blob/master/Cargo.lock#L6694-L6702
The package builds fine in a nix-shell, but fails in the
buildRustPackageenvironment.37 remaining items
vobloeb commentedon Aug 1, 2022
Can we get rid of broken
cargo vendorfor the purpose ofbuildRustPackage?We could reconstruct repository at
$HOME/.cargoinstead of./vendordirectory (akin to$HOME/.m2is reconstructed for java projects, which lack anymaven vendor).vobloeb commentedon Aug 1, 2022
Using
cargo vendorhas another issue: it tries to build every package under./vendor/, even those which are not suppose to built.For example, if you package TiKV, even after working around 3 duplicates, you'll hit at build failure of
./vendor/libtitan_sys-0.0.1- the package which should not be built as an independent package at all.kotatsuyaki commentedon Mar 1, 2023
I ran into this issue when trying to wgsl-analyzer. In their
idepackage, they use multiple versions of thenagalibrary on purpose. Working around the issue seems to require patching a substantial amount of Rust code (to drop support for all versions ofnagaexcept for one), which is not sustainable and results in lost of functionality.With the cancellation of rust-lang/cargo#10344 due to potential syntactic conflict with another Rust RFC, the problem is unlikely to be solved upstream soon. I support @kvtb's idea of migrating away from
cargo vendorforbuildRustPackage.Use bug/host_header branch for hyper-reverse-proxy
junjihashimoto commentedon Jan 9, 2024
I reimplemented
cargo vendor --no-merge-sourcesfor cargo.rust-lang/cargo#13271
junjihashimoto commentedon Jan 9, 2024
Actually, I don't know if it will be merged or not. This issue seems to be resolved by applying a patch to cargo.
junjihashimoto commentedon Jan 11, 2024
The cargo's build itself works with
cargo vendor, so we can use patched cargo.TomaSajt commentedon Feb 21, 2026
Closed via #387337 (merged into staging)
See https://nixpk.gs/pr-tracker.html?pr=387337 for progress towards reaching master.
fix nix build