From d88602f396013a9e043dc4d36b14676b098603c4 Mon Sep 17 00:00:00 2001 From: Rdbo <57117082+rdbo@users.noreply.github.com> Date: Wed, 2 Aug 2023 23:48:58 +0000 Subject: [PATCH] fixed cargo-generate binary download for musl (#166) Thank you for reworking the patch! --- src/ext/exe.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/ext/exe.rs b/src/ext/exe.rs index 37ef3906..74407be9 100644 --- a/src/ext/exe.rs +++ b/src/ext/exe.rs @@ -452,13 +452,23 @@ impl Command for CommandCargoGenerate { fn github_repo(&self) -> &'static str { "cargo-generate" } fn download_url(&self, target_os: &str, target_arch: &str, version: &str) -> Result { - let target = match (target_os, target_arch) { - ("macos", "aarch64") => "aarch64-apple-darwin", - ("linux", "aarch64") => "aarch64-unknown-linux-gnu", - ("macos", "x86_64") => "x86_64-apple-darwin", - ("windows", "x86_64") => "x86_64-pc-windows-msvc", - ("linux", "x86_64") => "x86_64-unknown-linux-gnu", - _ => bail!("No cargo-generate tar binary found for {target_os} {target_arch}"), + let is_musl_env = is_linux_musl_env(); + + let target = if is_musl_env { + match (target_os, target_arch) { + ("linux", "aarch64") => "aarch64-unknown-linux-musl", + ("linux", "x86_64") => "x86_64-unknown-linux-musl", + _ => bail!("No cargo-generate tar binary found for linux-musl {target_arch}"), + } + } else { + match (target_os, target_arch) { + ("macos", "aarch64") => "aarch64-apple-darwin", + ("linux", "aarch64") => "aarch64-unknown-linux-gnu", + ("macos", "x86_64") => "x86_64-apple-darwin", + ("windows", "x86_64") => "x86_64-pc-windows-msvc", + ("linux", "x86_64") => "x86_64-unknown-linux-gnu", + _ => bail!("No cargo-generate tar binary found for {target_os} {target_arch}"), + } }; Ok(format!(