fix(installer): preserve existing oh-my-zsh installation - #188
Open
eezzekl wants to merge 1 commit into
Open
Conversation
The installer copied a vendored oh-my-zsh snapshot over ~/.oh-my-zsh unconditionally. On a real oh-my-zsh git clone that dirties tracked files, so `omz update` (git pull --rebase with autostash) fails on the stash pop. On a clean system the snapshot has no .git, leaving an oh-my-zsh that can never update and fails silently. Install oh-my-zsh through its official installer only when ~/.oh-my-zsh is missing, and never write into an existing one. KEEP_ZSHRC=yes keeps the .zshrc the installer copies, RUNZSH/CHSH keep it non-interactive. The vendored copy carried no project-owned code: 1015 of its 1019 files matched upstream blobs verbatim and the rest were upstream-deleted plugins, so it is removed instead of kept in sync. Refs Gentleman-Programming#187
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.
Closes #187
Summary
GentlemanZsh/.oh-my-zshsnapshot over~/.oh-my-zshunconditionally, which dirties the tracked files of a real Oh My Zsh clone and makesomz updatefail on the autostash pop.~/.oh-my-zshis missing, and an existing installation is never written into.Changes
installer/internal/system/exec.goPathExistshelper next toEnsureDir. Resolves symlinks on purpose, so a symlinked~/.oh-my-zshcounts as installed.installer/internal/tui/installer.goshouldInstallOhMyZsh; thesystem.CopyDircall incase "zsh"is replaced by the guard plus the official installer.installer/internal/tui/installation_steps_test.goTestShouldInstallOhMyZshcovering missing, real-directory and symlinked-directory states.docs/manual-installation.mdcp -rf GentlemanZsh/.oh-my-zsh ~/replaced with a guarded official-installer invocation.GentlemanZsh/.oh-my-zshThe installer call is:
KEEP_ZSHRC=yesis what preserves the.zshrccopied a few lines above;RUNZSH/CHSHkeep it non-interactive. All three are documented in Oh My Zsh'stools/install.sh. This introduces no new dependency — the installer already clones tpm (installer.go:935), Alacritty, and runs the Homebrew installer viacurl.Why the vendored copy is safe to remove
Every bundled file was hashed and checked against Oh My Zsh's own history:
1015 of 1019 files matched an identical upstream blob. The remaining 4 are
plugins/fig/andplugins/rbfu/, also upstream files, whose blobs are missing only because upstream deleted those plugins.rg -i gentlemanover the tree returns nothing, and the directory has 3 commits in the entire repository history, all imports. There is nothing to migrate into$ZSH_CUSTOM.Worth noting for anyone who resolved these conflicts by hand: the
bundle_install()function in the bundledplugins/bundler/bundler.plugin.zshis deprecated Oh My Zsh code, not a Gentleman.Dots function. Upstream replaced it withalias bi="bundle install".Test plan
go test ./... -skip Golden -count=1— system 5.7s, tui 71.8s, trainer OKgo build ./cmd/gentleman-installerand--help/--versionsmoke testgo vet ./...clean.goldensnapshot references Oh My Zsh, so the macOS job is unaffectedcurlandgitNote on E2E
e2e_test.shruns--shell=zshthree times and its cleanup never removes$HOME/.oh-my-zsh, so the first run exercises the install path and the later runs exercise the guard — both branches get covered.One deliberate trade-off: the zsh E2E now needs to reach GitHub to install Oh My Zsh, where it previously only copied files. I did not soften the failure into a warning, because
.zshrcrunssource $ZSH/oh-my-zsh.sh— silently skipping the install would leave the user with a shell that breaks at startup. Failing the step is the safer behavior, but it is a new network dependency in that job and worth knowing about.