fix(ohmyzsh): unshallow clone after install so omz update works - #36
Merged
Conversation
The omz install.sh always does git clone --depth=1, which makes later 'omz update' invocations fail with: error: Could not read <hash> error: could not parse commit <hash> There was an error updating. Try again later? when the parent commits of merge tips get GC'd on the remote (or are otherwise unreachable from the depth-1 boundary). Fix: run 'git fetch --unshallow origin' right after the unattended install, with a directory guard and || true so it never breaks the boot path.
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.
Problem
When users run
omz update(the prompt that fires when a new omz release is detected), it fails with:Root cause
The omz installer script (
ohmyzsh/tools/install.shline 317) does:So
~/.oh-my-zshships as a shallow clone.omz updatelater runsgit pull, which needs to fetch the parent commits of the local tip to do the merge. Those parents are outside the depth-1 boundary, and once GitHub GCs them on origin (or force-pushes rewrite history), they're permanently unreachable — hence the "Could not read" error pointing at commit hashes that are merge tips' parents.Fix
After the unattended install, run
git fetch --unshallow originto convert the depth-1 clone into a full clone. Guarded with:if [ -d "$HOME/.oh-my-zsh/.git" ]— only runs if omz actually installed2>/dev/null || true— never blocks the boot path on network/partial-state issuesDiff
Cost
omz updateworks reliably for the lifetime of the containerTest plan
omz versionshowsis_repo: true, is_clean: ...git -C ~/.oh-my-zsh rev-parse --is-shallow-repository→falseomz update— should complete without "Could not read" errors