Skip to content

fix(installer): make Arch/CachyOS/Debian installs robust and preserve user shell configs - #220

Open
SrDylanCol wants to merge 17 commits into
Gentleman-Programming:mainfrom
SrDylanCol:fix/arch-cachyos-installer
Open

SrDylanCol wants to merge 17 commits into
Gentleman-Programming:mainfrom
SrDylanCol:fix/arch-cachyos-installer

Conversation

@SrDylanCol

Copy link
Copy Markdown

Summary

Hardens the Gentleman.Dots installer and shell configurations across Arch Linux, CachyOS, Debian/Ubuntu, and Zsh. Resolves multiple community-reported issues preventing installation, masking test failures, or destroying user configurations.

Changes Included

  1. Package Availability Hardening (Arch & Debian):

  2. Configuration & Repository Preservation:

  3. Zsh Runtime Integrations:

  4. CI & Testing:

Closes #183, Closes #174, Closes #185, Closes #187, Closes #193, Closes #194, Closes #195, Closes #196, Closes #205, Closes #206, Closes #210, Closes #215

Albe841114 and others added 13 commits August 29, 2026 08:59
Four defects reproduced on CachyOS/Arch:

- carapace and zsh-theme-powerlevel10k are AUR-only, and pacman is
  atomic, so one unresolvable name aborted every Arch install
- CopyDir handed Unix sockets to os.ReadFile, so one live socket failed
  the backup of every config
- rm -rf ran on a relative path at two sites with no git check,
  destroying uncommitted work
- --dry-run set GENTLEMAN_DRY_RUN and nothing read it

Refs Gentleman-Programming#182, Gentleman-Programming#174, Gentleman-Programming#190, Gentleman-Programming#192
A clean working tree proved only that nothing was uncommitted, not that
nothing would be lost. Committing local work made a checkout *more*
deletable, not less: `git status --porcelain` went empty, the guard
classified it as a clean checkout, and removal destroyed commits that
existed on no remote. This was observed destroying real work.

Add RepoUnpublishedWork. Deletion now requires the working tree to be
clean AND the repository's work to be published: no stash entries, and
HEAD contained by at least one remote-tracking branch. A repository with
no remotes, or one whose publication cannot be determined, fails closed.

The guard must not over-block either: a branch with no upstream whose
HEAD is already on a remote loses no commits, so it stays deletable.
Only the branch name would go, and that is not work.

Two earlier tests encoded the old assumption by building fixtures with
no remote and expecting deletion; their fixtures now publish to a bare
origin, so they still exercise the delete path.
Merge the four delta specs into openspec/specs/ and move the change
folder to changes/archive/2026-08-29-fix-arch-installer/.

The archive report records what the proposal and design do not: five
work units shipped, not four. Unit 5 was added after verification, when
the installer destroyed this change's own commits and exposed a flaw in
unit 3's guard — a clean working tree proves only that nothing is
uncommitted, not that nothing would be lost.

Also recorded: three defects found while doing this work that had no
upstream issue at the time — backup dying on Unix sockets, the
destructive relative-path rm -rf, and the E2E harness masking per-image
exit status. They have since been reported upstream as Gentleman-Programming#195, Gentleman-Programming#193 and
Gentleman-Programming#194 respectively, alongside Gentleman-Programming#196 for the fish configuration being
overwritten without a backup.
The Arch package lists are hardcoded, but the same name resolves differently
across Arch-based distributions. `pacman -S` is atomic, so a single unknown
name aborted the whole transaction and installed nothing.

- Resolve each requested package with `pacman -Si` before installing and drop
  the names the host cannot provide, with a visible warning per skipped name.
  This keeps `zsh-theme-powerlevel10k` on CachyOS, where it is packaged, while
  omitting it on vanilla Arch, where it is AUR-only, without a distro branch.
- Install carapace from the pinned static release (v1.8.2, SHA256 verified)
  when the repositories do not provide it, mirroring the Herdr installer.
  PR Gentleman-Programming#197 dropped carapace as an accepted tradeoff; the shell configs still
  reference it, so the completion feature was silently lost.
- Preserve an existing `~/.config/fish` before overwriting it when the run
  produced no global backup, so declining a backup cannot destroy user config.
- Fail only when no requested package is available at all.

Verified on CachyOS: carapace resolves nowhere, zsh-theme-powerlevel10k
resolves in the cachyos repo, and the remaining names resolve in extra.
docker-test.sh ran under `set -e` without `pipefail`, so a pipeline's exit
status was the last command's. The test runner invokes every image as
`run_image ... | tee $output`, and tee always succeeds, so a failing suite was
counted as a pass and the matrix went green while tests were failing.

- Switch to bash: POSIX sh has no `pipefail`.
- Enable `set -eo pipefail`, deliberately without `-u` (optional variables).
- Keep `shopt -s xpg_echo` so `echo "$COLOR..."` still interprets escapes,
  which dash did and bash does not.
- Guard the `[FAIL]` extraction with `|| true`: under pipefail a run that
  failed without printing any `[FAIL]` line would abort the whole script.
The Debian/Ubuntu package lists include `starship`, which is not packaged by
Debian or Ubuntu. `apt-get install -y` is atomic, so the whole shell step
failed for fish, zsh and nushell alike: the installer could not complete on
Ubuntu at all.

This is the same defect class fixed for Arch in 80c1b0d, so the resolution
logic is now shared instead of duplicated:

- Extract `installAvailablePackages`, parameterised by the availability probe
  and the native install command.
- Add `aptPackageAvailable` (`apt-cache show`, non-zero when unknown) and
  `installDebianPackages` alongside the Arch implementation.
- Rename arch_packages.go to native_packages.go, since it now covers both.

Packages the host cannot resolve are skipped with a visible warning; the step
fails only when nothing requested is available.
The installer copied the vendored snapshot (1019 files, ~11 MB) over
`~/.oh-my-zsh` unconditionally. On a machine where Oh My Zsh was installed the
official way, that marks every differing tracked file as a local modification;
the next `omz update` then fails on the autostash pop, because
`tools/upgrade.sh` runs `git pull --rebase` with `rebase.autoStash true`.

Oh My Zsh is a self-updating git checkout, not an installer-owned config file:

- Add `system.PathExists`, which follows symlinks so a dotfiles-managed
  `~/.oh-my-zsh` symlink counts as an installation.
- Add `installOhMyZshIfMissing`: copy the bundled snapshot only when no
  installation exists, and otherwise leave the user's checkout byte for byte
  untouched.

The bundled snapshot carries no project-owned files (its themes are upstream
Oh My Zsh themes and `custom/` holds Oh My Zsh's own examples), so skipping it
loses nothing.

Known limitation, deliberately out of scope: a fresh install still receives the
non-git snapshot, which cannot self-update either. Removing the vendored copy
and installing Oh My Zsh officially is the follow-up proposed in Gentleman-Programming#188.
With Zsh and powerlevel10k selected, the window manager chosen during install
(tmux, zellij or herdr) never autostarted. The launcher sat at the bottom of
the template, after the instant prompt block, which redirects stdout to a file
while the rest of .zshrc runs:

    exec ... 0<&$fd_null 1>&$fd_out

After that point `[[ -t 1 ]]` is false, so the launcher's guard never fired and
`exec $WM_CMD` was never reached.

Move the block above the instant prompt, where stdout is still the terminal,
and keep it self-contained. `PatchZshForWM` scans lines independently of their
position, so patching the selected window manager still works, including the
"none" case that removes the block entirely.

Add regression tests that read the real template, since the existing patch
tests use a synthetic fixture and could not catch the ordering.
…ing configs

- Add user extension directory loader for ~/.zshrc.d/*.zsh in GentlemanZsh/.zshrc (Gentleman-Programming#206)
- Generalize preserveExistingConfig to back up regular files with system.CopyFile
- Back up ~/.zshrc and ~/.p10k.zsh before copying new configurations
- Add unit tests for zsh template extension loader and file preservation
…man-Programming#205)

- Add gentleman-fzf-or-menu ZLE dispatcher widget after fzf eval in GentlemanZsh/.zshrc
- Delegate to fzf-completion only when typing the completion trigger (default **)
- Fall back to menu-select and preserve Tab / Shift+Tab menu navigation
- Add regression test in zsh_template_test.go
Copilot AI balanced review requested due to automatic review settings November 21, 2026 23:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…n-Programming#184) and fix zsh-autocomplete load order (Gentleman-Programming#199)

- Filter Fedora dnf package lists by availability (dnf info) and fall back to standalone verified Carapace binary (Gentleman-Programming#184)
- Prefer maintained scottames/ghostty COPR on Fedora with fallback to pgdev/ghostty (Gentleman-Programming#184)
- Load oh-my-zsh.sh before zsh-autocomplete and source zsh-syntax-highlighting last with Zsh 5.9 widget stubs (Gentleman-Programming#199)
…n-Programming#181) and verify Homebrew tap formula sync (Gentleman-Programming#175)

- Disable osc633 by default and use exec $MULTIPLEXER in GentlemanNushell/config.nu and PatchNushellForWM (Gentleman-Programming#181)
- Add TestTapFormulaSync to verify homebrew-tap formula version and SHA-256 checksums (Gentleman-Programming#175)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment