Skip to content

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

fix: bundle mlx.metallib via Tauri resources for DMG compatibility

Louis Beaumont642da17ac144
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml
index f540ffc4b..532630950 100644
--- a/.github/workflows/release-app.yml
+++ b/.github/workflows/release-app.yml
@@ -909,25 +909,6 @@ jobs:
if bunx tauri build -v $TAURI_ARGS 2>&1 | tee /tmp/tauri-build-$attempt.log; then
echo "✅ Build succeeded on attempt $attempt"
cd ../..
-
- # Bundle mlx.metallib into the .app for parakeet-mlx (macOS aarch64 only)
- # MLX searches for mlx.metallib next to the binary before falling back to
- # the hardcoded build path (which doesn't exist on user machines).
- if [[ "${{ matrix.target }}" == "aarch64-apple-darwin" ]]; then
- METALLIB=$(find "apps/screenpipe-app-tauri/src-tauri/target/${{ matrix.target }}/release/build" -path "*/mlx-sys-*/mlx.metallib" -print -quit 2>/dev/null)
- if [ -n "$METALLIB" ]; then
- APP_DIR=$(find "apps/screenpipe-app-tauri/src-tauri/target/${{ matrix.target }}/release/bundle" -name "screenpipe.app" -type d -print -quit 2>/dev/null)
- if [ -n "$APP_DIR" ]; then
- cp "$METALLIB" "$APP_DIR/Contents/MacOS/mlx.metallib"
- echo "✅ Bundled mlx.metallib into $APP_DIR/Contents/MacOS/"
- else
- echo "⚠️ Could not find screenpipe.app bundle dir"
- fi
- else
- echo "⚠️ mlx.metallib not found in build artifacts"
- fi
- fi
-
break
fi
cd ../..
diff --git a/apps/screenpipe-app-tauri/src-tauri/build.rs b/apps/screenpipe-app-tauri/src-tauri/build.rs
index 2ff8a7c40..6fe2c8fc2 100644
--- a/apps/screenpipe-app-tauri/src-tauri/build.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/build.rs
@@ -358,6 +358,40 @@ fn main() {
build_shortcut_reminder();
}
+ // Copy mlx.metallib to a known location so Tauri can bundle it as a resource.
+ // MLX compiles Metal shaders into this file during mlx-sys build. Without it,
+ // parakeet-mlx crashes with "Failed to load the default metallib".
+ #[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
+ if let Some(build_dir) = std::path::Path::new(&out_dir).ancestors().nth(3) {
+ 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-") {
+ let metallib = entry.path().join("out/build/_deps/mlx-build/mlx/backend/metal/kernels/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;
+ }
+ }
+ }
+ }
+ }
+ if !found {
+ println!("cargo:warning=mlx.metallib not found in build artifacts (parakeet-mlx may not be enabled)");
+ }
+ }
+ }
+
tauri_build::build()
}
diff --git a/apps/screenpipe-app-tauri/src-tauri/mlx.metallib b/apps/screenpipe-app-tauri/src-tauri/mlx.metallib
new file mode 100644
index 000000000..e69de29bb
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
index 5cff70386..9effa266c 100755
--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -1066,6 +1066,25 @@ async fn main() {
env::set_var("TESSDATA_PREFIX", tessdata_path);
}
+ // Ensure mlx.metallib is discoverable by MLX (parakeet-mlx).
+ // Tauri bundles it in Contents/Resources/ but MLX looks next to the binary
+ // (Contents/MacOS/). Create a symlink so both paths work.
+ #[cfg(target_os = "macos")]
+ {
+ if let Ok(exe) = std::env::current_exe() {
+ let macos_dir = exe.parent().unwrap_or(std::path::Path::new("."));
+ let target = macos_dir.join("mlx.metallib");
+ if !target.exists() {
+ // Try Contents/Resources/mlx.metallib (Tauri resource)
+ let resource = macos_dir.parent()
+ .map(|contents| contents.join("Resources/mlx.metallib"));
+ if let Some(src) = resource.filter(|p| p.exists()) {
+ let _ = std::os::unix::fs::symlink(&src, &target);
+ }
+ }
+ }
+ }
+
// Autostart setup
let autostart_manager = app.autolaunch();
diff --git a/apps/screenpipe-app-tauri/src-tauri/tauri.conf.json b/apps/screenpipe-app-tauri/src-tauri/tauri.conf.json
index 2ae07775f..2ddba8178 100644
--- a/apps/screenpipe-app-tauri/src-tauri/tauri.conf.json
+++ b/apps/screenpipe-app-tauri/src-tauri/tauri.conf.json
@@ -36,7 +36,8 @@
"icons/screenpipe-logo-tray-black.png"
],
"resources": [
- "assets/*"
+ "assets/*",
+ "mlx.metallib"
],
"macOS": {
"entitlements": "entitlements.plist",
diff --git a/apps/screenpipe-app-tauri/src-tauri/tauri.prod.conf.json b/apps/screenpipe-app-tauri/src-tauri/tauri.prod.conf.json
index 07fd8523e..dea3b310e 100644
--- a/apps/screenpipe-app-tauri/src-tauri/tauri.prod.conf.json
+++ b/apps/screenpipe-app-tauri/src-tauri/tauri.prod.conf.json
@@ -39,7 +39,8 @@
"icons/screenpipe-logo-tray-black.png"
],
"resources": [
- "assets/*"
+ "assets/*",
+ "mlx.metallib"
],
"macOS": {
"entitlements": "entitlements.plist",