Nix-installed `strip` is crashing `cargo install`

I tried running cargo install --force cargo-make today and was surprised to get a SIGKILL:

cargo install --force cargo-make
    Updating crates.io index
  Installing cargo-make v0.36.11
    Updating crates.io index
^[[C       Fetch [=================>               ] 74 complete; 38 pending
   Compiling proc-macro2 v1.0.65
   Compiling quote v1.0.30
   Compiling unicode-ident v1.0.11
   Compiling libc v0.2.147
   Compiling cfg-if v1.0.0
   Compiling serde v1.0.171
   Compiling memchr v2.5.0
   Compiling cc v1.0.79
   Compiling autocfg v1.1.0
   Compiling regex-syntax v0.7.4
error: failed to run custom build command for `memchr v2.5.0`

Caused by:
  process didn't exit successfully: `/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/cargo-install6IaAul/release/build/memchr-7d041391a35b68d0/build-script-build` (signal: 9, SIGKILL: kill)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `serde v1.0.171`

Caused by:
  process didn't exit successfully: `/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/cargo-install6IaAul/release/build/serde-8f92dd0ae7270fc0/build-script-build` (signal: 9, SIGKILL: kill)
error: failed to compile `cargo-make v0.36.11`, intermediate artifacts can be found at `/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/cargo-install6IaAul`

Tinkering with my cargo config, I eventually found that this seemed to be the issue:

[profile.release]
strip = true

I'm on an M1 Mac, and I was able to find this instructive issue, in which a homebrew-installed strip was the culprit. It that led me to prove that having the nix-installed strip on my path was indeed the problem:

$ type -a strip
strip is /run/current-system/sw/bin/strip
strip is /usr/bin/strip
$
$ # this crashes, as it has the nix-installed `strip` in PATH
$ PATH=/run/current-system/sw/bin:/usr/bin:/nix/store/g1cmgw0rnaqkak5nhlj6pay6jcna7giq-rustup-1.26.0/bin /run/current-system/sw/bin/cargo install --force cargo-make
$
$ # same command -- but removing the path containing nix's `strip` -- succeeds
$ PATH=/usr/bin:/nix/store/g1cmgw0rnaqkak5nhlj6pay6jcna7giq-rustup-1.26.0/bin /run/current-system/sw/bin/cargo install --force cargo-make
$
$ # architecture looks right
$ file "$(nix build --print-out-paths --no-link nixpkgs#binutils-unwrapped | grep -v man)"/bin/strip
/nix/store/p5sf021g9a1g085x1y49yw1k0380aly7-binutils-2.40/bin/strip: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>

Are there any other aarch64-darwin nix users that know how I can keep strip = true enabled but tell cargo to use the system's strip?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.