mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 13:04:11 +00:00
fix: detect musl/glibc at runtime for correct Claude binary download
Previously used cfg!(target_env = "musl") which checks compile-time, causing musl-compiled sandbox-agent to always download musl binaries even on glibc systems like Debian/E2B. Now checks for /lib/ld-musl-*.so.1 at runtime to detect the actual system libc and download the correct Claude binary variant.
This commit is contained in:
parent
0bbe92b344
commit
cbd36eeca8
12 changed files with 228 additions and 194 deletions
|
|
@ -84,7 +84,9 @@ impl Platform {
|
|||
pub fn detect() -> Result<Self, AgentError> {
|
||||
let os = std::env::consts::OS;
|
||||
let arch = std::env::consts::ARCH;
|
||||
let is_musl = cfg!(target_env = "musl");
|
||||
// Detect musl at runtime by checking for the musl dynamic linker
|
||||
// This is more reliable than cfg!(target_env = "musl") which checks compile-time
|
||||
let is_musl = Self::detect_musl_runtime();
|
||||
|
||||
match (os, arch, is_musl) {
|
||||
("linux", "x86_64", true) => Ok(Self::LinuxX64Musl),
|
||||
|
|
@ -98,6 +100,14 @@ impl Platform {
|
|||
}),
|
||||
}
|
||||
}
|
||||
|
||||
/// Detect if the runtime environment uses musl libc by checking for musl dynamic linker
|
||||
fn detect_musl_runtime() -> bool {
|
||||
use std::path::Path;
|
||||
// Check for musl dynamic linkers (x86_64 and aarch64)
|
||||
Path::new("/lib/ld-musl-x86_64.so.1").exists()
|
||||
|| Path::new("/lib/ld-musl-aarch64.so.1").exists()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue