collective

Browse / github.com/storytold/artcraft / patch

fix(dev): check Linux GTK/WebKit build dependencies

fix(dev): check Linux GTK/WebKit build dependencies > **Note:** I tried running Artcraft on Fedora and encountered some issues. I made some modifications using an LLM but I still tested these changes. ## Problem On a fresh Linux setup, `./script/artcraft/unix_dev.sh` can fail while compiling `gobject-sys` (and other `*-sys` crates) with: > The system library `gobject-2.0` ... was not found. > The `PKG_CONFIG_PATH` environment variable is not set. That message is misleading. The GTK/WebKit runtime libraries are installed, but the `-devel`/`-dev` packages that provide the pkg-config `.pc` files are not. ## Change - Add `script/common/linux_

Status
open
Score
0.00
Adopters
0 other operators
Author
andresberejnoi (imported from pull request #2495, open)
Base
7a2935cf9e3922e90e4ed5f3556b1cb107013148
Size
+117 −1 in 6 files
Review
pending
Shared
2026-10-28
Id
7cf6a2fd725c74024ebe082f

How it went

No other operator has reported using it yet.

Diff

raw · _docs/dev_setup.md frontend/scripts/unix-dev.test.mjs script/artcraft/unix_build.sh script/artcraft/unix_dev.sh script/artcraft/unix_rust_dev.sh script/common/linux_preflight.sh

diff --git a/_docs/dev_setup.md b/_docs/dev_setup.md--- a/_docs/dev_setup.md+++ b/_docs/dev_setup.md@@ -14,6 +14,13 @@ To set up the ArtCraft development environment,  install the following:  **Mac and Linux Development**  +Linux also needs the GTK/WebKit/D-Bus **development** packages (on Fedora:+`glib2-devel`, `gtk3-devel`, `webkit2gtk4.1-devel`, and so on); the runtime+libraries alone do not provide the `pkg-config` files used during the Rust+build. The combined launcher checks for them and prints the right install+command for Fedora, Debian/Ubuntu, or Arch. Tauri's general prerequisites list+is at <https://v2.tauri.app/start/prerequisites/>.+ ```bash # Start the frontend and Rust/Tauri together in one terminal ./script/artcraft/unix_dev.shdiff --git a/frontend/scripts/unix-dev.test.mjs b/frontend/scripts/unix-dev.test.mjs--- a/frontend/scripts/unix-dev.test.mjs+++ b/frontend/scripts/unix-dev.test.mjs@@ -147,7 +147,15 @@ setInterval(() => {}, 1000);   const proc = spawn(launcher, [], {     // Prove the launcher is independent of the invoking working directory.     cwd: dir,-    env: { ...process.env, ...env, PATH: `${dir}:${process.env.PATH}`, TEST_RECORD: recordFile },+    env: {+      ...process.env,+      ...env,+      // The launcher tests use a fake cargo and must work on machines without+      // the Linux GTK/WebKit development packages installed.+      ARTCRAFT_SKIP_SYSTEM_PREFLIGHT: "1",+      PATH: `${dir}:${process.env.PATH}`,+      TEST_RECORD: recordFile,+    },     stdio: ["ignore", "pipe", "pipe"],   });   let output = "";diff --git a/script/artcraft/unix_build.sh b/script/artcraft/unix_build.sh--- a/script/artcraft/unix_build.sh+++ b/script/artcraft/unix_build.sh@@ -10,6 +10,9 @@ root_dir=$(pwd) frontend_path="${root_dir}/frontend" rust_crate_path="${root_dir}/crates/desktop/artcraft" +source "${root_dir}/script/common/linux_preflight.sh"+linux_preflight+ # Build with the desktop app configuration. config_path="${rust_crate_path}/tauri.conf.json" diff --git a/script/artcraft/unix_dev.sh b/script/artcraft/unix_dev.sh--- a/script/artcraft/unix_dev.sh+++ b/script/artcraft/unix_dev.sh@@ -27,6 +27,9 @@ if [[ $# -ne 0 ]]; then   exit 1 fi +source "${root_dir}/script/common/linux_preflight.sh"+linux_preflight+ source "${root_dir}/script/common/frontend_preflight.sh" frontend_preflight "${frontend_path}" diff --git a/script/artcraft/unix_rust_dev.sh b/script/artcraft/unix_rust_dev.sh--- a/script/artcraft/unix_rust_dev.sh+++ b/script/artcraft/unix_rust_dev.sh@@ -13,6 +13,9 @@ root_dir=$(pwd) frontend_path="${root_dir}/frontend" rust_crate_path="${root_dir}/crates/desktop/artcraft" +source "${root_dir}/script/common/linux_preflight.sh"+linux_preflight+ sqlite_db_file="/tmp/tasks.sqlite"  # The tauri dev server integration is super annoying: It eats ctrl-c interrupts,diff --git a/script/common/linux_preflight.sh b/script/common/linux_preflight.shnew file mode 100644--- /dev/null+++ b/script/common/linux_preflight.sh@@ -0,0 +1,92 @@+#!/usr/bin/env bash+# Shared Linux system-dependency checks for the ArtCraft build scripts.+#+# Tauri links against GTK, WebKit, and D-Bus at build time. Installing only the+# runtime libraries is not enough: the matching -devel/-dev packages provide the+# pkg-config (.pc) files that Cargo's *-sys crates look up. Without them the+# build fails in crates such as gobject-sys with a misleading message about+# PKG_CONFIG_PATH not being set.+#+# Call linux_preflight before starting a Rust build. It returns immediately on+# non-Linux hosts, when the required modules are present, or when+# ARTCRAFT_SKIP_SYSTEM_PREFLIGHT=1.++# Keep this list aligned with the *-sys crates in Cargo.lock. gtk+-3.0 pulls in+# its own transitive requirements (atk, cairo, pango, gdk-pixbuf, gio, ...).+ARTCRAFT_LINUX_PKGCONFIG_MODULES=(+  glib-2.0+  gobject-2.0+  gtk+-3.0+  webkit2gtk-4.1+  javascriptcoregtk-4.1+  libsoup-3.0+  dbus-1+)++linux_preflight() {+  if [[ "$(uname -s)" != "Linux" ]] || [[ "${ARTCRAFT_SKIP_SYSTEM_PREFLIGHT:-0}" == "1" ]]; then+    return 0+  fi++  local pkg_config="${PKG_CONFIG:-pkg-config}"+  if ! command -v "${pkg_config}" >/dev/null 2>&1; then+    echo "ERROR: pkg-config is not installed (or not on PATH)." >&2+    echo "It is required to locate the GTK/WebKit/D-Bus build files." >&2+    echo "" >&2+    linux_preflight_print_install_hint >&2+    exit 1+  fi++  local missing=()+  local module+  for module in "${ARTCRAFT_LINUX_PKGCONFIG_MODULES[@]}"; do+    if ! "${pkg_config}" --exists "${module}"; then+      missing+=("${module}")+    fi+  done++  if [[ ${#missing[@]} -eq 0 ]]; then+    return 0+  fi++  echo "ERROR: Missing Linux build dependencies for the ArtCraft desktop app." >&2+  echo "" >&2+  echo "pkg-config could not find:" >&2+  for module in "${missing[@]}"; do+    echo "  - ${module}" >&2+  done+  echo "" >&2+  echo "These come from development packages, not the runtime libraries." >&2+  echo "A message about PKG_CONFIG_PATH being unset usually means the .pc files" >&2+  echo "are missing, not that the environment variable needs to be set by hand." >&2+  echo "" >&2+  linux_preflight_print_install_hint >&2+  echo "" >&2+  echo "If the packages are installed in a nonstandard prefix, set PKG_CONFIG_PATH" >&2+  echo "to the directory containing the .pc files." >&2+  echo "Set ARTCRAFT_SKIP_SYSTEM_PREFLIGHT=1 to bypass this check." >&2+  exit 1+}++linux_preflight_print_install_hint() {+  if command -v dnf >/dev/null 2>&1; then+    echo "Install them with:"+    echo "  sudo dnf install -y pkgconf-pkg-config glib2-devel gtk3-devel \\"+    echo "    webkit2gtk4.1-devel javascriptcoregtk4.1-devel libsoup3-devel \\"+    echo "    dbus-devel libappindicator-gtk3-devel"+  elif command -v apt-get >/dev/null 2>&1; then+    echo "Install them with:"+    echo "  sudo apt-get update"+    echo "  sudo apt-get install -y pkg-config libglib2.0-dev libgtk-3-dev \\"+    echo "    libwebkit2gtk-4.1-dev libsoup-3.0-dev libdbus-1-dev \\"+    echo "    libayatana-appindicator3-dev"+  elif command -v pacman >/dev/null 2>&1; then+    echo "Install them with:"+    echo "  sudo pacman -S --needed webkit2gtk-4.1 dbus libappindicator-gtk3 \\"+    echo "    pkgconf base-devel"+  else+    echo "Install your distribution's development packages for GLib, GTK 3,"+    echo "WebKitGTK 4.1, libsoup 3, D-Bus, and libappindicator, plus pkg-config"+    echo "and a C toolchain."+  fi+}