Skip to content

Commit dc484b6

Browse files
fix(desktop): fail fast on missing linux deps (anomalyco#848)
1 parent 73d716f commit dc484b6

3 files changed

Lines changed: 73 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Before running `pnpm dev`, ensure these are installed and active in your shell:
8484
- **Bun 1.3.9+** (`bun --version`)
8585
- Rust toolchain (for Tauri), with Cargo from current `rustup` stable (supports `Cargo.lock` v4)
8686
- Xcode Command Line Tools (macOS)
87+
- On Linux, WebKitGTK 4.1 development packages so `pkg-config` can resolve `webkit2gtk-4.1` and `javascriptcoregtk-4.1`
8788

8889
### One-minute sanity check
8990

@@ -126,6 +127,7 @@ All repo `dev` entrypoints now opt into the same dev-mode isolation so local tes
126127
### Arch Users:
127128

128129
```bash
130+
sudo pacman -S --needed webkit2gtk-4.1
129131
yay -s opencode # Releases version
130132
```
131133

‎packages/desktop/scripts/tauri-before-dev.mjs‎

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { spawn, spawnSync } from "node:child_process";
2+
import { readFileSync } from "node:fs";
23
import { resolve } from "node:path";
34
import { fileURLToPath } from "node:url";
45

@@ -68,7 +69,7 @@ const holdOpenUntilSignal = ({ uiChild } = {}) => {
6869
// alive with a timer until Tauri stops the dev process.
6970
const timer = setInterval(() => {}, 60_000);
7071

71-
let stopping = false;
72+
let stopping = false;
7273

7374
const stop = () => {
7475
if (stopping) return;
@@ -124,6 +125,73 @@ const runPrepareSidecars = () => {
124125
}
125126
};
126127

128+
const readLinuxReleaseInfo = () => {
129+
try {
130+
const content = readFileSync("/etc/os-release", "utf8");
131+
const values = new Map();
132+
for (const line of content.split(/\r?\n/)) {
133+
if (!line || line.startsWith("#") || !line.includes("=")) continue;
134+
const separator = line.indexOf("=");
135+
const key = line.slice(0, separator);
136+
const rawValue = line.slice(separator + 1).trim();
137+
const value = rawValue.replace(/^"|"$/g, "");
138+
values.set(key, value);
139+
}
140+
return {
141+
id: values.get("ID") ?? "",
142+
like: values.get("ID_LIKE") ?? "",
143+
prettyName: values.get("PRETTY_NAME") ?? values.get("NAME") ?? "Linux",
144+
};
145+
} catch {
146+
return { id: "", like: "", prettyName: "Linux" };
147+
}
148+
};
149+
150+
const getLinuxDesktopDependencyHint = () => {
151+
const release = readLinuxReleaseInfo();
152+
const family = `${release.id} ${release.like}`.toLowerCase();
153+
154+
if (family.includes("arch")) {
155+
return "Install the missing desktop dependency and retry:\n sudo pacman -S --needed webkit2gtk-4.1";
156+
}
157+
158+
if (family.includes("ubuntu") || family.includes("debian")) {
159+
return (
160+
"Install the missing desktop dependencies and retry:\n" +
161+
" sudo apt install libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev"
162+
);
163+
}
164+
165+
if (family.includes("fedora") || family.includes("rhel")) {
166+
return (
167+
"Install the missing desktop dependencies and retry:\n" +
168+
" sudo dnf install webkit2gtk4.1-devel openssl-devel curl wget file libappindicator-gtk3-devel librsvg2-devel"
169+
);
170+
}
171+
172+
return `Install WebKitGTK 4.1 development packages for ${release.prettyName} so pkg-config can resolve both webkit2gtk-4.1 and javascriptcoregtk-4.1, then retry.`;
173+
};
174+
175+
const ensureLinuxDesktopDependencies = () => {
176+
if (process.platform !== "linux") return;
177+
178+
const requiredPkgConfigs = ["webkit2gtk-4.1", "javascriptcoregtk-4.1"];
179+
const missing = requiredPkgConfigs.filter((pkg) => {
180+
const result = spawnSync("pkg-config", ["--exists", pkg], { stdio: "ignore" });
181+
return result.status !== 0;
182+
});
183+
184+
if (missing.length === 0) return;
185+
186+
console.error(
187+
"[openwork] Missing Linux desktop system dependencies required by Tauri:\n" +
188+
` ${missing.join(", ")}\n\n` +
189+
`${getLinuxDesktopDependencyHint()}\n\n` +
190+
"If you only need the web UI, run `pnpm dev:ui`."
191+
);
192+
process.exit(1);
193+
};
194+
127195
const runUiDevServer = () => {
128196
const child = spawn(pnpmCmd, ["-w", "dev:ui"], {
129197
stdio: "inherit",
@@ -156,6 +224,7 @@ const runUiDevServer = () => {
156224
};
157225

158226
runPrepareSidecars();
227+
ensureLinuxDesktopDependencies();
159228

160229
const main = async () => {
161230
let detectedViteUrl = null;

‎packaging/aur/PKGBUILD‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pkgdesc="An Open source alternative to Claude Cowork"
55
arch=('x86_64' 'aarch64')
66
url="https://github.com/different-ai/openwork"
77
license=('MIT')
8+
# webkit2gtk-4.1 provides both webkit2gtk-4.1.pc and javascriptcoregtk-4.1.pc
89
depends=('gtk3' 'glib2' 'libayatana-appindicator' 'libsoup3' 'webkit2gtk-4.1' 'openssl' 'dbus' 'librsvg')
910

1011
# Architecture-specific sources and checksums

0 commit comments

Comments
 (0)