omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

omarchy install terminal <pkg> reports failure but still mutates xdg-terminals.list and copies config when package is missing on aarch64

Open ozz1ee-dev opened this issue 3 months ago • 3 comments

Bug

Running omarchy install terminal ghostty on aarch64 prints "Failed to install ghostty" but still:

  1. Copies /usr/share/omarchy/config/ghostty/ into ~/.config/ghostty/
  2. Overwrites ~/.config/xdg-terminals.list so it points at com.mitchellh.ghostty.desktop

The package was never installed (pacman -Q | grep ghostty is empty afterwards, no ghostty binary on PATH), but xdg-terminal-exec and any Hyprland keybinding that resolves the default terminal now look for ghostty and fail to launch a terminal.

Steps to reproduce

  1. Use Omarchy on aarch64 (Apple Silicon). Ghostty is not in the aarch64 repos and there is no ghostty package in AUR (aur/ghostty does not exist; only derivatives like ghostty-git / ghostty-nightly-bin).
  2. Run omarchy install terminal ghostty.

What happens

Installing ghostty...
Skipping 'ghostty': not available in the repos on this system

But then the script silently:

  • creates ~/.config/ghostty/ (copied from /usr/share/omarchy/config/ghostty/)
  • rewrites ~/.config/xdg-terminals.list to:
    com.mitchellh.ghostty.desktop
    

The user has no terminal they can launch and no package they can run.

Expected

When the package cannot be installed, omarchy install terminal should:

  • Print the error and exit non-zero
  • Leave ~/.config/xdg-terminals.list unchanged
  • Leave ~/.config/<package>/ untouched

Root cause

omarchy install terminal (in /usr/bin/omarchy-install-terminal) gates the config-copy and xdg-terminals.list rewrite on if omarchy-pkg-add $package; then. But omarchy-pkg-add (in /usr/bin/omarchy-pkg-add) does exit 0 when none of the requested packages are installable:

to_install=()
for pkg in "$@"; do
  if pacman -Q "$pkg" &>/dev/null || pacman -Si "$pkg" &>/dev/null; then
    to_install+=("$pkg")
  else
    echo -e "\033[33mSkipping '$pkg': not available in the repos on this system\033[0m" >&2
  fi
done

((${#to_install[@]})) || exit 0

So the if branch fires, even though no package was actually installed. The script needs a separate "did anything actually get installed?" check (e.g. omarchy-pkg-present $package after the call, or a non-zero exit from omarchy-pkg-add when nothing was installable).

Environment

  • Omarchy 4.0.1-2
  • aarch64 (Apple M1, Icestorm)
  • Kernel: Linux 7.1.6-1-1-ARCH

ozz1ee-dev avatar Aug 31 '26 12:08 ozz1ee-dev

Opened a fix in https://github.com/omacom/omarchy/pull/9365.

Repro

Isolated HOME with a stub omarchy-pkg-add that prints the skip line and exits 0 without installing (the shape from the report), against stock omarchy-install-terminal on quattro:

Installing ghostty...
Skipping 'ghostty': not available in the repos on this system
EXIT:0
xdg-terminals.list → com.mitchellh.ghostty.desktop
~/.config/ghostty/ created

Two cooperating bugs, not just one:

  1. Success branch ran on omarchy-pkg-add exit 0 without checking the package was present.
  2. Failure branch printed Failed to install … but exited 0, so omarchy-default-terminal --install (which does omarchy-install-terminal || exit 1) continued and rewrote the default anyway — confirmed in the same harness.

Fix

Require omarchy-pkg-add success and omarchy-pkg-present before seeding config or rewriting xdg-terminals.list; exit non-zero on failure.

# after
Installing ghostty...
Skipping 'ghostty': not available in the repos on this system
Failed to install ghostty
EXIT:1
xdg-terminals.list left at kitty.desktop
~/.config/ghostty absent

Tests

test/shell.d/install-terminal-test.sh covers:

  • pkg-add non-zero → no mutation, exit 1
  • pkg-add exit 0 without package present (this issue) → no mutation, exit 1
  • successful install sets desktop id + seeds config
  • existing config not overwritten
  • omarchy-default-terminal --install preserves previous default when install fails
$ bash test/shell.d/install-terminal-test.sh
… 6 ok
$ bash test/shell.d/default-apps-test.sh
… ok (terminals still install before selection)

fresh3nough avatar Aug 31 '26 13:08 fresh3nough

Reporter verification, run on the machine from the report.

Box: MacBook Air M1 (2020), aarch64, omarchy 4.0.1-2, kernel 7.1.6.asahi1-1. Script under test: stock /usr/bin/omarchy-install-terminal (md5 5fb4229412aa8ac00e30d30b637618fa), driven with an isolated HOME and a stub omarchy-pkg-add that prints the skip line and exits 0 (the same shape as your repro).

Before (4.0.1-2, unpatched)

  • direct omarchy-install-terminal ghostty: EXIT:0, ~/.config/xdg-terminals.list rewritten to com.mitchellh.ghostty.desktop, ~/.config/ghostty created, pacman -Q ghostty empty afterwards.
  • through omarchy-default-terminal --install ghostty: kitty.desktop -> com.mitchellh.ghostty.desktop and the "Ghostty is now the default terminal" notification fires, EXIT:0. So the box both loses its working terminal default and is told the switch succeeded.

Your branch at head aefa83e, same stub

  • direct: Failed to install ghostty, EXIT:1, xdg-terminals.list left at kitty.desktop, ~/.config/ghostty absent.
  • through omarchy-default-terminal --install ghostty: EXIT:1, xdg-terminals.list left at kitty.desktop.

Confirmed on the aarch64 path: both cooperating bugs reproduce exactly as described and the fix resolves both, with the previous default preserved on failure. I also checked that the presence gate does not lock out the derived packages mentioned in the original report - pacman -Q resolves provides as well (pacman -Q sh reports the installed bash here), so ghostty-git / ghostty-nightly-bin machines still satisfy omarchy-pkg-present ghostty.

Thanks for picking this up, and for wiring it into test/shell.d/.

ozz1ee-dev avatar Sep 21 '26 20:09 ozz1ee-dev

Reviewed against quattro (fcf9eeb) and v4.0.1, reading the source; nothing was run on a worker, since the mechanism is a few lines of control flow and #9365 is verified as its own item.

The omarchy-pkg-add quoted in the report, with the "Skipping '…': not available in the repos on this system" loop and the exit 0 when nothing is installable, is not Omarchy's. No version of it exists in this repository's history, v4.0.1 included. Omarchy's bin/omarchy-pkg-add runs pacman -S, exits 1 if that fails, and exits 1 again if pacman -Q still cannot find the package afterwards. The Apple M1 install the manual points to (manual/49-omarchy-on.md) is a community port on Asahi Alarm, which presumably carries its own copy; the skip-and-succeed behaviour, and the config copy that follows from it, come from there rather than from Omarchy.

There is a real bug in the same place on stock quattro, though, and it gives the same end result:

  • bin/omarchy-install-terminal ends its failure branch with echo "Failed to install $package", so it exits 0 when the install fails. Called directly, it leaves ~/.config/<terminal> and xdg-terminals.list alone, but reports success.
  • bin/omarchy-default-terminal --install relies on that status (omarchy-install-terminal "$terminal" || exit 1, line 41), so after a failed install it goes on to rewrite xdg-terminals.list to the uninstalled terminal and sends the "is now the default terminal" notification.

That --install path came in with #6950 (b724f76) and is not in a release yet, so 4.0.x users are not affected by it.

#9365 fixes it: the failure branch now exits 1, which stops omarchy-default-terminal before it touches the default. Its added omarchy-pkg-present check is redundant against Omarchy's own omarchy-pkg-add but harmless. It is already linked to close this issue.

Reviewed by Claude Opus 5.5 and, as a second opinion, Codex Medium, which agreed with these findings from the source and added that v4.0.1's omarchy-default-terminal has no --install path at all; independence between the two is not guaranteed. This is waiting on the maintainer's decision on #9365.

omarchybot avatar Oct 09 '26 10:10 omarchybot