Skip to content

buildRustPackage: found duplicate version of package #30742

Closed

Description

@ljli

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

Activity

  1. wizeman commented on Oct 25, 2017

    @wizeman
    Member
  2. zimbatm commented on Oct 26, 2017

    @zimbatm
    Member

    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.

  3. alex-ameen commented on Aug 11, 2018

    @alex-ameen
    Contributor

    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?

  4. ljli commented on Sep 6, 2018

    @ljli
    ContributorAuthor

    FTR, cargo-vendor has a flag (--no-merge-sources) now which solves the root problem. If buildRustPackage gets adapted, crates like spotifyd should work.

  5. bobvanderlinden commented on Sep 22, 2018

    @bobvanderlinden
    Member

    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:

    nix-shell -p cargo -p alsaLib -p libpulseaudio -p pkgconfig -p openssl -p dbus
    cargo build --release --features pulseaudio_backend
    
  6. ljli commented on Sep 23, 2018

    @ljli
    ContributorAuthor

    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:

    cargo vendor $out | cargo-vendor-normalise > config

    I'll try to have a look tomorrow.

  7. ljli commented on Sep 23, 2018

    @ljli
    ContributorAuthor

    My first attempt to hook up --no-merge-sources is 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:

    $ 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.

  8. boomshroom commented on Oct 8, 2018

    @boomshroom
    Contributor

    Could you perhaps submit a pull request for that? I'm running into the same problem.

  9. zimbatm commented on Sep 13, 2019

    @zimbatm
    Member

    A bunch of things have changed on the rust packaging side which probably fix this issue. Ping me if I should re-open.

  10. bqv commented on Feb 18, 2020

    @bqv
    Contributor

    @zimbatm I think this issue is still quite relevant. See:

    rustPlatform.buildRustPackage {
                pname = "weechat-discord";
                version = "test";
    
                src = fetchFromGitHub {
                  owner = "terminal-discord";
                  repo = "weechat-discord";
                  rev = "e09bac671b14c389f9909d8393ab76a575c5df73";
                  sha256 = "0n1681vn0w2a4zjfmaimbbjsfpc5aflp9rr5w7j3zh1mp87wnxdj";
                };
    
                cargoSha256 = "0000000000000000000000000000000000000000000000000000";
    
                buildInputs = [
                ];
              }

    Which for me, fails with:

      (...)
      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
    
  11. zimbatm commented on Feb 18, 2020

    @zimbatm
    Member

    On what version of nixpkgs did you experience the issue?
    What are the instructions to reproduce this error independently?

  12. bqv commented on Feb 18, 2020

    @bqv
    Contributor

    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

  13. FlorianFranzen commented on Mar 19, 2020

    @FlorianFranzen
    Contributor

    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:

    https://github.com/paritytech/polkadot/blob/master/Cargo.lock#L6694-L6702

    The package builds fine in a nix-shell, but fails in the buildRustPackage environment.

  14. 37 remaining items

  15. vobloeb commented on Aug 1, 2022

    @vobloeb
    Contributor

    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).

  16. vobloeb commented on Aug 1, 2022

    @vobloeb
    Contributor

    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.

  17. kotatsuyaki commented on Mar 1, 2023

    @kotatsuyaki
    Contributor

    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.

  18. junjihashimoto commented on Jan 9, 2024

    @junjihashimoto
    Member

    I reimplemented cargo vendor --no-merge-sources for cargo.
    rust-lang/cargo#13271

  19. junjihashimoto commented on Jan 9, 2024

    @junjihashimoto
    Member

    Actually, I don't know if it will be merged or not. This issue seems to be resolved by applying a patch to cargo.

  20. junjihashimoto commented on Jan 11, 2024

    @junjihashimoto
    Member

    The cargo's build itself works with cargo vendor, so we can use patched cargo.

  21. added
    2.status: stale
    on Jul 3, 2025
  22. TomaSajt commented on Feb 21, 2026

    @TomaSajt
    Contributor

    Closed via #387337 (merged into staging)
    See https://nixpk.gs/pr-tracker.html?pr=387337 for progress towards reaching master.

  23. added a commit that references this issue on Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

2.status: stale

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions