From a9e33e5c58a76958c7733202cab32fdedeb2eeb2 Mon Sep 17 00:00:00 2001 From: Don Williams Date: Mon, 3 Nov 2025 12:21:18 -0500 Subject: [PATCH] ags: fix GIRepository ESM import error by exporting GI_TYPELIB_PATH and dropping GIRepository prepend calls Context: - On systems where AGS v1 installs its typelibs to /usr/local/lib, gjs ESM imports like gi://GIRepository?version=2.0 fail with: "Typelib file for namespace 'GIRepository', version '2.0' not found" even though typelibs exist under /usr/lib{,64}/girepository-1.0. - The upstream AGS launcher tries to call GIR.Repository.prepend_search_path()/prepend_library_path(), but in recent GI (1.86) these are not available from the ESM namespace. Changes: - Replace import GIR from "gi://GIRepository?version=2.0" with import GLib from "gi://GLib" in the installed launcher. - Remove deprecated GIR.Repository.prepend_search_path and prepend_library_path calls. - Immediately after the GLib import, export GI_TYPELIB_PATH in-process so gjs finds typelibs under /usr/local/lib: const __old = GLib.getenv('GI_TYPELIB_PATH'); GLib.setenv('GI_TYPELIB_PATH', '/usr/local/lib' + (__old ? ':' + __old : ''), true); Result: - ags -t overview no longer errors on GIRepository; proceeds until a GTK display is required. - Behavior is scoped to the AGS process; no user shell env changes required. Notes: - Verified by patching an installed launcher on a target host; GI errors resolved. --- install-scripts/ags.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/install-scripts/ags.sh b/install-scripts/ags.sh index 8c741dc..74ff0a6 100755 --- a/install-scripts/ags.sh +++ b/install-scripts/ags.sh @@ -83,6 +83,25 @@ if git clone --depth=1 https://github.com/JaKooLit/ags_v1.9.0.git; then meson setup build if sudo meson install -C build 2>&1 | tee -a "$MLOG"; then printf "\n${OK} ${YELLOW}Aylur's GTK shell $ags_tag${RESET} installed successfully.\n" 2>&1 | tee -a "$MLOG" + + # Patch installed AGS launcher to ensure GI typelibs in /usr/local/lib are discoverable in GJS ESM + printf "${NOTE} Applying AGS launcher patch for GI typelibs search path...\n" + LAUNCHER="/usr/local/share/com.github.Aylur.ags/com.github.Aylur.ags" + if sudo test -f "$LAUNCHER"; then + # 1) Switch from GIRepository ESM import to GLib and drop deprecated prepend_* calls + sudo sed -i \ + -e 's|^import GIR from "gi://GIRepository?version=2.0";$|import GLib from "gi://GLib";|' \ + -e '/GIR.Repository.prepend_search_path/d' \ + -e '/GIR.Repository.prepend_library_path/d' \ + "$LAUNCHER" + + # 2) Inject GI_TYPELIB_PATH export right after the GLib import + sudo awk '{print} $0 ~ /^import GLib from "gi:\/\/GLib";$/ {print "const __old = GLib.getenv(\"GI_TYPELIB_PATH\");"; print "GLib.setenv(\"GI_TYPELIB_PATH\", \"/usr/local/lib\" + (__old ? \":\" + __old : \"\"), true);"}' "$LAUNCHER" | sudo tee "$LAUNCHER" >/dev/null + + printf "${OK} AGS launcher patched.\n" + else + printf "${WARN} Launcher not found at $LAUNCHER, skipping patch.\n" + fi else echo -e "\n${ERROR} ${YELLOW}Aylur's GTK shell $ags_tag${RESET} Installation failed\n " 2>&1 | tee -a "$MLOG" fi @@ -95,4 +114,4 @@ else exit 1 fi -printf "\n%.0s" {1..2} \ No newline at end of file +printf "\n%.0s" {1..2}