alexcrichton / cargo-vendor

Archived as subcommand is now part of Cargo itself
Apache License 2.0
261 stars 30 forks source link

Error parsing manifest with lto = "thin" on NixOS #267

Closed sondr3 closed 5 years ago

sondr3 commented 5 years ago

One of my programs just ran into this error when trying to build it for NixOS:

error: failed to parse manifest at `/build/source/Cargo.toml`

Caused by:
  invalid type: string "thin", expected a boolean for key `profile.release.lto`
Traceback (most recent call last):
  File "/nix/store/47xr1p4bl84vysnn6v329dayyls1acqg-cargo-vendor-normalise/bin/.cargo-vendor-normalise-wrapped", line 42, in <module>
    main()
  File "/nix/store/47xr1p4bl84vysnn6v329dayyls1acqg-cargo-vendor-normalise/bin/.cargo-vendor-normalise-wrapped", line 17, in main
    assert list(data.keys()) == ["source"]
AssertionError
builder for '/nix/store/m2z5bi1a51p6pcl5cknws28ci9xh6zyw-git-ignore-2019-04-17-vendor.drv' failed with exit code 1
cannot build derivation '/nix/store/3kmyfjbx1cb2ww01qkhipidp11vmyri6-git-ignore-2019-04-17.drv': 1 dependencies couldn't be built
error: build of '/nix/store/3kmyfjbx1cb2ww01qkhipidp11vmyri6-git-ignore-2019-04-17.drv' failed

With the relevant parts of my Cargo.toml here:

[profile.release]
lto = "thin"

This builds fine locally on my machine with cargo build [--release], but when I try to build it in NixOS and my derivation for it the error above pops up. I tried tracking down where it could come from myself but as far as I understood it the configuration itself calls out to the Cargo library itself and I quickly got lost in the source code due to the size and my lack of familiarity with it.

I found that it is supposed to be a StringOrBool here. From the cargo manifest it can indeed be both, but at this point I'm out of ideas as to what might be the cause of this. Any ideas where this might come from?

NixOS system information ```text - system: `"x86_64-linux"` - host os: `Linux 5.0.7, NixOS, 19.03.172138.5c52b25283a (Koi)` - multi-user?: `yes` - sandbox: `yes` - version: `nix-env (Nix) 2.2` - channels(root): `"nixos-19.03.172138.5c52b25283a, unstable-19.09pre174426.acbdaa569f4"` - channels(sondre): `""` - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos` ```
Nix derivation ```nix { stdenv, fetchFromGitHub, rustPlatform, pkgconfig, openssl, darwin }: with rustPlatform; buildRustPackage rec { name = "git-ignore-${version}"; version = "2019-04-17"; cargoSha256 = "1fqfy8lnvpn5sd3l73x2p359zq4303vsrdgw3aphvy6580yjb84d"; src = fetchFromGitHub { owner = "sondr3"; repo = "git-ignore"; rev = "0075815beb69ce2647d7fb5384d90533eee847f4"; sha256 = "1hx4z1l510rqd2kr01c33r97w3l6gm46wl2f799jc2647klfxscq"; }; nativeBuildInputs = [ pkgconfig ]; buildInputs = [ openssl ] ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ]; preFixup = '' mkdir -p "$out/man/man1" cp target/git-ignore.1 "$out/man/man1/" ''; meta = with stdenv.lib; { description = "Quickly and easily fetch .gitignore templates from gitignore.io"; homepage = https://github.com/sondr3/git-ignore; license = licenses.gpl3Plus; platforms = platforms.all; maintainers = [ maintainers.sondr3 ]; }; } ```
alexcrichton commented 5 years ago

Thanks for the report! I suspect though that this is an outdated version of cargo-vendor and an update is needed, but if that doesn't work please let me know!

sondr3 commented 5 years ago

Whoops, yeah, you're correct. The cargo-vendor version in NixOS is practically ancient. That explains it, thanks!

evanjs commented 5 years ago

For those coming here from Google or such: I believe this was fixed with https://github.com/NixOS/nixpkgs/pull/57017

sondr3 commented 5 years ago

Correct, this is now fixed and works as it should in Nix(OS) :smile: