nix-community / crate2nix

rebuild only changed crates in CI with crate2nix and nix
https://nix-community.github.io/crate2nix/
Apache License 2.0
338 stars 82 forks source link

`found invalid metadata files for crate` on darwin; can't install #263

Open symphorien opened 1 year ago

symphorien commented 1 year ago

On darwin Cargo.nix files can fail to build due to found invalid metadata files for crate XXXX.

This happened with cfg_if while building crossbeam-utils (in the CI of nix-du, on github actions) but also while installing crate2nix itself with nix-env -i -f https://github.com/kolloch/crate2nix/tarball/master

building '/nix/store/0blklm2lnw0hf3mmjc1c492gn50ry5gm-rust_byteorder-1.4.3.drv'...
unpacking sources
unpacking source archive /nix/store/64wdmbi3ag3h941sjsiqvfx33r5jl59w-byteorder-1.4.3.tar.gz
source root is byteorder-1.4.3
patching sources
configuring
Running cd .
building
Building src/lib.rs (byteorder)
Running rustc --crate-name byteorder src/lib.rs --out-dir target/lib -L dependency=target/deps --cap-lints allow -C opt-level=3 -C codegen-units=1 --remap-path-prefix=/private/tmp/nix-build-rust_byteorder-1.4.3.drv-0=/ --edition 2018 -C metadata=c965296940 -C extra-filename=-c965296940 --crate-type lib --color always
installing
post-installation fixup
strip is /nix/store/4a65pmhh8p4aj935xvbjc6qsl2pc59sw-cctools-binutils-darwin-973.0.1/bin/strip
patching script interpreter paths in /nix/store/skksb20aam1qp9avhabxjd5p56xc7mhp-rust_byteorder-1.4.3
strip is /nix/store/4a65pmhh8p4aj935xvbjc6qsl2pc59sw-cctools-binutils-darwin-973.0.1/bin/strip
stripping (with command strip and flags -S) in  /nix/store/0yj5ipnxh062ghb526fmcl6dcc40y6wa-rust_byteorder-1.4.3-lib/lib
patching script interpreter paths in /nix/store/0yj5ipnxh062ghb526fmcl6dcc40y6wa-rust_byteorder-1.4.3-lib
building '/nix/store/h9jsgmsf1nyhban2zz5wgaks8w9kcdq7-rust_block-padding-0.1.5.drv'...
unpacking sources
unpacking source archive /nix/store/l3f584l4pyfydymrx26f84hfbcfgi4xz-block-padding-0.1.5.tar.gz
source root is block-padding-0.1.5
setting SOURCE_DATE_EPOCH to timestamp 1573142851 of file block-padding-0.1.5/Cargo.toml.orig
patching sources
configuring
Running cd .
building
Building src/lib.rs (block-padding)
Running rustc --crate-name block_padding src/lib.rs --out-dir target/lib -L dependency=target/deps --cap-lints allow -C opt-level=3 -C codegen-units=1 --remap-path-prefix=/private/tmp/nix-build-rust_block-padding-0.1.5.drv-0=/ --extern byte_tools=/nix/store/ag5s2vrj323mfrg4x9cdh3k2kjv3giin-rust_byte-tools-0.3.1-lib/lib/libbyte_tools-04b4404b6a.rlib --cfg feature="default" --edition 2015 -C metadata=11da2fc2da -C extra-filename=-11da2fc2da --crate-type lib --color always
error[E0786]: found invalid metadata files for crate `byte_tools`
 --> src/lib.rs:9:1
  |
9 | extern crate byte_tools;
  | ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: no `.rmeta` section in '/nix/store/ag5s2vrj323mfrg4x9cdh3k2kjv3giin-rust_byte-tools-0.3.1-lib/lib/libbyte_tools-04b4404b6a.rlib'

error: aborting due to previous error

For more information about this error, try `rustc --explain E0786`.
error: builder for '/nix/store/h9jsgmsf1nyhban2zz5wgaks8w9kcdq7-rust_block-padding-0.1.5.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/05b4h69rf4daiyxnx59sbzdn5j8py1kd-rust_pest_meta-2.1.3.drv' failed to build
error: 1 dependencies of derivation '/nix/store/cd1lvw9s564w3wllkxww6pm97fg38hf4-rust_crate2nix-0.10.0.drv' failed to build
abathur commented 1 year ago

I started seeing these while trying to adopt flakes in a project. I did a poor-man's bisect on hydra-built versions and see the failure, at least on my end, emerge between the hydra evals for 4f8287f3d597c73b0d706cfad028c2d51821f64d (https://hydra.nixos.org/build/196107950) and 31acb601e388eb7d552f137dbe5cb4677fdf1c3c (https://hydra.nixos.org/build/196366738).

There's still a ton in that window--it looks like there was a big staging merge.

I suspect this is related to the trouble documented in nixos/nixpkgs#185656 and nixos/nixpkgs#196815

symphorien commented 1 year ago

ah so disabling stripping maybe works ?

bouk commented 10 months ago

There's a PR on nixpkgs to fix this now: https://github.com/NixOS/nixpkgs/pull/255900