YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: use find command in build.rs to locate mlx.metallib reliably
Louis Beaumontdd1e92b95f9e
diff --git a/apps/screenpipe-app-tauri/src-tauri/build.rs b/apps/screenpipe-app-tauri/src-tauri/build.rsindex 485c6b986..0b17d07c1 100644--- a/apps/screenpipe-app-tauri/src-tauri/build.rs+++ b/apps/screenpipe-app-tauri/src-tauri/build.rs@@ -364,36 +364,46 @@ fn main() {#[cfg(all(target_os = "macos", target_arch = "aarch64"))]{let out_dir = std::env::var("OUT_DIR").unwrap_or_default();- // Navigate from OUT_DIR (target/{profile}/build/{crate}-{hash}/out/)- // up to the build/ dir to find mlx-sys's metallib- // OUT_DIR is target/{target}/release/build/{crate}-{hash}/out/- // We need the build/ dir which is 2 levels up- if let Some(build_dir) = std::path::Path::new(&out_dir).ancestors().nth(2) {- let mut found = false;- if let Ok(entries) = std::fs::read_dir(build_dir) {- for entry in entries.flatten() {- if entry.file_name().to_string_lossy().starts_with("mlx-sys-") {- // metallib can be at either path depending on cmake config- let base = entry.path().join("out/build");- let metallib = base.join("_deps/mlx-build/mlx/backend/metal/kernels/mlx.metallib");- let metallib = if metallib.exists() { metallib } else { base.join("lib/mlx.metallib") };- if metallib.exists() {- let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();- let dest = std::path::Path::new(&manifest_dir).join("mlx.metallib");- if let Err(e) = std::fs::copy(&metallib, &dest) {- println!("cargo:warning=Failed to copy mlx.metallib: {}", e);- } else {- println!("cargo:warning=Copied mlx.metallib to {}", dest.display());- found = true;- break;- }+ println!("cargo:warning=mlx-metallib: OUT_DIR={}", out_dir);++ // Find mlx.metallib compiled by mlx-sys. Use `find` for robustness —+ // the exact path varies by target triple, profile, and cmake version.+ let mut found = false;+ // Walk up to find the target dir (contains the "build" subdir with all crate builds)+ let mut search_root = std::path::PathBuf::from(&out_dir);+ // Go up until we find a directory that contains "build" as a direct child+ for _ in 0..8 {+ if search_root.join("build").is_dir() {+ break;+ }+ if !search_root.pop() { break; }+ }+ let build_dir = search_root.join("build");+ println!("cargo:warning=mlx-metallib: searching in {}", build_dir.display());++ if build_dir.is_dir() {+ // Use std::process::Command to find the metallib — more reliable than manual traversal+ if let Ok(output) = std::process::Command::new("find")+ .args([build_dir.to_str().unwrap_or("."), "-name", "mlx.metallib", "-print", "-quit"])+ .output()+ {+ let path = String::from_utf8_lossy(&output.stdout).trim().to_string();+ if !path.is_empty() {+ let metallib = std::path::Path::new(&path);+ let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();+ let dest = std::path::Path::new(&manifest_dir).join("mlx.metallib");+ match std::fs::copy(metallib, &dest) {+ Ok(bytes) => {+ println!("cargo:warning=mlx-metallib: copied {} bytes from {} to {}", bytes, path, dest.display());+ found = true;}+ Err(e) => println!("cargo:warning=mlx-metallib: copy failed: {}", e),}}}- if !found {- println!("cargo:warning=mlx.metallib not found in build artifacts (parakeet-mlx may not be enabled)");- }+ }+ if !found {+ println!("cargo:warning=mlx-metallib: not found (parakeet-mlx may not be enabled)");}}