Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(mac): three macOS-broken Rust paths (backup dir, Ollama probe, cloudflared)

purple898ff72135f1
diff --git a/src-tauri/src/commands/process.rs b/src-tauri/src/commands/process.rs
index 2dbe1137..914d5d13 100644
--- a/src-tauri/src/commands/process.rs
+++ b/src-tauri/src/commands/process.rs
@@ -1519,18 +1519,15 @@ pub fn get_ollama_host(state: State<'_, AppState>) -> Result<serde_json::Value,
/// Auto-start Ollama on app launch (called from setup)
pub fn auto_start_ollama(state: &AppState) {
- // Check if already running
- {
- let mut cmd = Command::new("tasklist");
- cmd.args(["/FI", "IMAGENAME eq ollama.exe"]);
- #[cfg(target_os = "windows")]
- cmd.creation_flags(CREATE_NO_WINDOW);
- if let Ok(output) = cmd.output() {
- let stdout = String::from_utf8_lossy(&output.stdout);
- if stdout.contains("ollama.exe") {
- println!("[Ollama] Already running");
- return;
- }
+ // Already running? Probe the API port cross-platform. The old check shelled
+ // out to Windows-only `tasklist`, which silently no-op'd on macOS/Linux, so
+ // those re-spawned `ollama serve` at every boot (redundant when Ollama was
+ // already up).
+ if let Ok(addr) = "127.0.0.1:11434".parse() {
+ if std::net::TcpStream::connect_timeout(&addr, std::time::Duration::from_millis(300)).is_ok()
+ {
+ println!("[Ollama] Already running");
+ return;
}
}
diff --git a/src-tauri/src/commands/remote.rs b/src-tauri/src/commands/remote.rs
index d260f336..20d68df0 100644
--- a/src-tauri/src/commands/remote.rs
+++ b/src-tauri/src/commands/remote.rs
@@ -4418,6 +4418,30 @@ pub async fn start_tunnel(
return Err("cloudflared download failed integrity check (unexpected file header)".into());
}
+ // macOS ships cloudflared as a gzip tarball (.tgz), not a raw binary —
+ // writing it straight to cf_path and exec'ing it is an ENOEXEC. Extract
+ // the `cloudflared` executable from the archive (system `tar` is always
+ // present on macOS). Windows/Linux download the raw binary.
+ #[cfg(target_os = "macos")]
+ {
+ let tgz = dir.join("cloudflared.tgz");
+ std::fs::write(&tgz, &bytes).map_err(|e| format!("write tgz: {}", e))?;
+ let status = std::process::Command::new("tar")
+ .arg("-xzf")
+ .arg(&tgz)
+ .arg("-C")
+ .arg(dir)
+ .status()
+ .map_err(|e| format!("tar spawn: {}", e))?;
+ let _ = std::fs::remove_file(&tgz);
+ if !status.success() {
+ return Err("Failed to extract cloudflared from its .tgz archive".into());
+ }
+ if !cf_path.exists() {
+ return Err("cloudflared binary missing after extracting the archive".into());
+ }
+ }
+ #[cfg(not(target_os = "macos"))]
std::fs::write(&cf_path, &bytes).map_err(|e| format!("write: {}", e))?;
// Make executable on Unix
diff --git a/src-tauri/src/commands/system.rs b/src-tauri/src/commands/system.rs
index 81e46142..2c321c80 100644
--- a/src-tauri/src/commands/system.rs
+++ b/src-tauri/src/commands/system.rs
@@ -160,10 +160,21 @@ pub fn exit_app(app: tauri::AppHandle) {
app.exit(0);
}
-/// Get the persistent settings dir (%APPDATA%/Locally Uncensored/) — outside NSIS install dir
+/// Get the persistent settings dir — outside the (NSIS) install dir so it
+/// survives updates. On Windows this stays `%APPDATA%/Locally Uncensored` (the
+/// path existing installs already back up to). `APPDATA` is Windows-only, so on
+/// macOS/Linux the whole backup/restore + onboarding-marker cluster used to
+/// hard-error; there we use the shared app data dir instead.
fn persistent_dir() -> Result<std::path::PathBuf, String> {
- let appdata = std::env::var("APPDATA").map_err(|_| "APPDATA not set".to_string())?;
- Ok(std::path::PathBuf::from(appdata).join("Locally Uncensored"))
+ #[cfg(target_os = "windows")]
+ {
+ let appdata = std::env::var("APPDATA").map_err(|_| "APPDATA not set".to_string())?;
+ Ok(std::path::PathBuf::from(appdata).join("Locally Uncensored"))
+ }
+ #[cfg(not(target_os = "windows"))]
+ {
+ Ok(crate::os_paths::data_dir().join("stores"))
+ }
}
/// Backup all localStorage stores to %APPDATA% (survives NSIS updates)