From 3cc28ba64d36a91b19e4d43f7cf2ef6f1ae56079 Mon Sep 17 00:00:00 2001 From: wavezhang Date: Thu, 11 Jun 2026 14:11:27 +0800 Subject: [PATCH] fix: gate keyring behind not(target_env = "musl") for static builds When targeting x86_64-unknown-linux-musl, the keyring crate's linux-native-sync-persistent feature pulls in libdbus-sys which cannot link against musl. Gate the OS keyring dependency behind not(target_env = "musl") so musl builds fall back to the file-backed secret store instead. Co-Authored-By: Claude Opus 4.7 --- crates/secrets/Cargo.toml | 2 +- crates/secrets/src/lib.rs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/secrets/Cargo.toml b/crates/secrets/Cargo.toml index 7db781eb..58c804fb 100644 --- a/crates/secrets/Cargo.toml +++ b/crates/secrets/Cargo.toml @@ -19,7 +19,7 @@ keyring = { version = "3", features = ["apple-native"] } [target.'cfg(target_os = "windows")'.dependencies] keyring = { version = "3", features = ["windows-native"] } -[target.'cfg(all(target_os = "linux", not(target_env = "ohos")))'.dependencies] +[target.'cfg(all(target_os = "linux", not(target_env = "ohos"), not(target_env = "musl")))'.dependencies] keyring = { version = "3", features = ["linux-native-sync-persistent", "crypto-rust"] } [dev-dependencies] diff --git a/crates/secrets/src/lib.rs b/crates/secrets/src/lib.rs index 53e4012a..81c7047e 100644 --- a/crates/secrets/src/lib.rs +++ b/crates/secrets/src/lib.rs @@ -127,7 +127,7 @@ impl DefaultKeyringStore { #[cfg(any( target_os = "macos", target_os = "windows", - all(target_os = "linux", not(target_env = "ohos")) + all(target_os = "linux", not(target_env = "ohos"), not(target_env = "musl")) ))] { // `Entry::new` is enough to validate the native macOS/Windows @@ -156,7 +156,7 @@ impl DefaultKeyringStore { #[cfg(not(any( target_os = "macos", target_os = "windows", - all(target_os = "linux", not(target_env = "ohos")) + all(target_os = "linux", not(target_env = "ohos"), not(target_env = "musl")) )))] { let _ = &self.service; @@ -170,7 +170,7 @@ impl KeyringStore for DefaultKeyringStore { #[cfg(any( target_os = "macos", target_os = "windows", - all(target_os = "linux", not(target_env = "ohos")) + all(target_os = "linux", not(target_env = "ohos"), not(target_env = "musl")) ))] { let entry = keyring::Entry::new(&self.service, key) @@ -184,7 +184,7 @@ impl KeyringStore for DefaultKeyringStore { #[cfg(not(any( target_os = "macos", target_os = "windows", - all(target_os = "linux", not(target_env = "ohos")) + all(target_os = "linux", not(target_env = "ohos"), not(target_env = "musl")) )))] { let _ = key; @@ -196,7 +196,7 @@ impl KeyringStore for DefaultKeyringStore { #[cfg(any( target_os = "macos", target_os = "windows", - all(target_os = "linux", not(target_env = "ohos")) + all(target_os = "linux", not(target_env = "ohos"), not(target_env = "musl")) ))] { let entry = keyring::Entry::new(&self.service, key) @@ -208,7 +208,7 @@ impl KeyringStore for DefaultKeyringStore { #[cfg(not(any( target_os = "macos", target_os = "windows", - all(target_os = "linux", not(target_env = "ohos")) + all(target_os = "linux", not(target_env = "ohos"), not(target_env = "musl")) )))] { let _ = (key, value); @@ -220,7 +220,7 @@ impl KeyringStore for DefaultKeyringStore { #[cfg(any( target_os = "macos", target_os = "windows", - all(target_os = "linux", not(target_env = "ohos")) + all(target_os = "linux", not(target_env = "ohos"), not(target_env = "musl")) ))] { let entry = keyring::Entry::new(&self.service, key) @@ -233,7 +233,7 @@ impl KeyringStore for DefaultKeyringStore { #[cfg(not(any( target_os = "macos", target_os = "windows", - all(target_os = "linux", not(target_env = "ohos")) + all(target_os = "linux", not(target_env = "ohos"), not(target_env = "musl")) )))] { let _ = key; @@ -249,7 +249,7 @@ impl KeyringStore for DefaultKeyringStore { #[cfg(not(any( target_os = "macos", target_os = "windows", - all(target_os = "linux", not(target_env = "ohos")) + all(target_os = "linux", not(target_env = "ohos"), not(target_env = "musl")) )))] fn unsupported_keyring_message() -> String { "system keyring backend is unsupported on this platform".to_string()