Repository navigation
fix(installer): make Arch/CachyOS/Debian installs robust and preserve user shell configs - #220
Open
SrDylanCol wants to merge 17 commits into
Open
SrDylanCol wants to merge 17 commits into
SrDylanCol wants to merge 17 commits into
Conversation
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
…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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Package Availability Hardening (Arch & Debian):
pacman -Si/apt-cache show) in a single transaction, avoiding complete step aborts due to unresolvable names (On CachyOS (Arch-based), Gentle AI 2.2.0 fails during "Install Zsh" because it runs: #183, [Bug]: Installation fails on Arch Linux due to package name mismatch (zsh dependencies) #174, Ubuntu/Debian: shell step always fails — starship is not in Debian/Ubuntu repos (same RCA as #166, unfixed for the Debian branch) #215).carapacestandalone from official releases with SHA-256 verification when missing from Arch/CachyOS repos (fix(installer): install carapace from static release on Arch #185).Configuration & Repository Preservation:
~/.config/fishbefore copying templates (Installer overwrites ~/.config/fish with a static copy, destroying user configuration #196).~/.zshrcand~/.p10k.zshbefore overwriting (feat(installer): preserve user Zsh customizations across updates #206).~/.oh-my-zshgit checkout, preventingomz updatecollisions (Installer overwrites ~/.oh-my-zsh with a static copy, breaking omz update #187).rm -rf Gentleman.Dotsuses a CWD-relative path and can delete an unrelated directory #193) and skip live Unix sockets during backups (Backup aborts when a directory being backed up contains a Unix socket #195).Zsh Runtime Integrations:
start_if_needed) above Powerlevel10k instant prompt so multiplexers (tmux/zellij/herdr) can start (bug(zsh): the window manager never autostarts while powerlevel10k's instant prompt is enabled #210, fix(zsh): start the window manager above the p10k instant prompt #211).~/.zshrc.d/*.zshin lexical order (feat(installer): preserve user Zsh customizations across updates #206).zsh-autocompleteinteractive menu navigation withfzfcompletion trigger**<Tab>viagentleman-fzf-or-menudispatcher (fix(zsh): integrate zsh-autocomplete menu navigation with fzf #205).CI & Testing:
pipefailininstaller/e2e/docker-test.shso pipe failures are properly reported (docker-test.sh reports success when a command inside a pipeline fails (no pipefail) #194).Closes #183, Closes #174, Closes #185, Closes #187, Closes #193, Closes #194, Closes #195, Closes #196, Closes #205, Closes #206, Closes #210, Closes #215