Skip to content

Commit 3625de1

Browse files
committed
fix(desktop): unbundle opencode binary and set NO_STRIP for AppImage build
opencode (Go binary) crashes linuxdeploy's ldd scanner, breaking AppImage bundling. Moved to PATH-only detection instead of bundling. Also set NO_STRIP=true to avoid linuxdeploy strip errors on newer system libraries with .relr.dyn sections.
1 parent 87933f3 commit 3625de1

File tree

3 files changed

+19
-66
lines changed

3 files changed

+19
-66
lines changed

apps/desktop/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"scripts": {
66
"dev": "tauri dev",
7-
"build": "tauri build",
7+
"build": "NO_STRIP=true tauri build",
88
"tauri": "tauri"
99
},
1010
"dependencies": {

apps/desktop/src-tauri/src/opencode.rs

Lines changed: 17 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
//! OpenCode CLI detection module
2-
31
use serde::Serialize;
42
use std::path::PathBuf;
53
use std::process::Command;
64
use which::which;
75

8-
/// Status of OpenCode CLI installation
96
#[derive(Debug, Clone, Serialize, PartialEq)]
107
pub struct OpenCodeStatus {
118
pub found: bool,
@@ -23,54 +20,27 @@ impl Default for OpenCodeStatus {
2320
}
2421
}
2522

26-
#[tauri::command]
27-
pub fn check_opencode() -> OpenCodeStatus {
28-
// First check bundled sidecar next to our own binary
29-
if let Ok(exe) = std::env::current_exe() {
30-
if let Some(bin_dir) = exe.parent() {
31-
let target_triple = env!("TARGET");
32-
let bundled = bin_dir.join(format!("opencode-{}", target_triple));
33-
if bundled.exists() {
34-
let version = Command::new(&bundled)
35-
.arg("--version")
36-
.output()
37-
.ok()
38-
.and_then(|output| {
39-
if output.status.success() {
40-
String::from_utf8(output.stdout).ok()
41-
} else {
42-
String::from_utf8(output.stderr).ok()
43-
}
44-
})
45-
.map(|s| s.trim().to_string())
46-
.filter(|s| !s.is_empty());
47-
48-
return OpenCodeStatus {
49-
found: true,
50-
version,
51-
path: Some(bundled.to_string_lossy().to_string()),
52-
};
23+
fn get_opencode_version(binary_path: &std::path::Path) -> Option<String> {
24+
Command::new(binary_path)
25+
.arg("--version")
26+
.output()
27+
.ok()
28+
.and_then(|output| {
29+
if output.status.success() {
30+
String::from_utf8(output.stdout).ok()
31+
} else {
32+
String::from_utf8(output.stderr).ok()
5333
}
54-
}
55-
}
34+
})
35+
.map(|s| s.trim().to_string())
36+
.filter(|s| !s.is_empty())
37+
}
5638

57-
// Fall back to system PATH
39+
#[tauri::command]
40+
pub fn check_opencode() -> OpenCodeStatus {
5841
match which("opencode") {
5942
Ok(path) => {
60-
let version = Command::new(&path)
61-
.arg("--version")
62-
.output()
63-
.ok()
64-
.and_then(|output| {
65-
if output.status.success() {
66-
String::from_utf8(output.stdout).ok()
67-
} else {
68-
String::from_utf8(output.stderr).ok()
69-
}
70-
})
71-
.map(|s| s.trim().to_string())
72-
.filter(|s| !s.is_empty());
73-
43+
let version = get_opencode_version(&path);
7444
OpenCodeStatus {
7545
found: true,
7646
version,
@@ -93,11 +63,6 @@ pub fn pick_local_folder() -> Option<String> {
9363
.map(|path| path.to_string_lossy().to_string())
9464
}
9565

96-
#[allow(dead_code)]
97-
fn check_binary_exists(binary_name: &str) -> bool {
98-
which(binary_name).is_ok()
99-
}
100-
10166
fn default_home_dir() -> Option<PathBuf> {
10267
std::env::var_os("HOME")
10368
.or_else(|| std::env::var_os("USERPROFILE"))
@@ -116,18 +81,6 @@ mod tests {
11681
assert!(status.path.is_none());
11782
}
11883

119-
#[test]
120-
fn test_check_binary_exists_with_common_binary() {
121-
assert!(check_binary_exists("ls"));
122-
}
123-
124-
#[test]
125-
fn test_check_binary_exists_with_nonexistent_binary() {
126-
assert!(!check_binary_exists(
127-
"this-binary-definitely-does-not-exist-12345"
128-
));
129-
}
130-
13184
#[test]
13285
fn test_check_opencode_returns_valid_structure() {
13386
let status = check_opencode();

apps/desktop/src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"icon": [
3535
"icons/icon.png"
3636
],
37-
"externalBin": ["binaries/openlinear-sidecar", "binaries/opencode"],
37+
"externalBin": ["binaries/openlinear-sidecar"],
3838
"resources": {
3939
"../../sidecar/dist/sidecar-entry.cjs": "sidecar-entry.cjs"
4040
},

0 commit comments

Comments
 (0)