Skip to content

fix(installer): clear an unmerged git index before stashing on update - #45515

Merged
teknium1 merged 2 commits into
NousResearch:mainfrom
xxxigm:fix/installer-unmerged-index
Jun 13, 2026
Merged

fix(installer): clear an unmerged git index before stashing on update#45515
teknium1 merged 2 commits into
NousResearch:mainfrom
xxxigm:fix/installer-unmerged-index

Conversation

@xxxigm

@xxxigm xxxigm commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

First-time/update installs fail at the repository stage with git checkout main failed (exit 1) when the existing checkout at $INSTALL_DIR has an unmerged index (files in a "needs merge" state left by a previously interrupted update).

The update path runs git stash then git checkout <branch>. On a conflicted index:

  • git stash aborts with error: could not write index
  • git checkout <branch> then aborts with error: you need to resolve your current index first → exit 1

…which the desktop/bootstrap installer surfaces as git checkout main failed (exit 1) and the whole install fails.

The hermes update Python path already handles this (#4735) by clearing the conflict with git reset before stashing; the installer scripts never got the same fix.

Changes

  • scripts/install.sh and scripts/install.ps1: before the autostash, detect unmerged entries with git ls-files --unmerged and clear the index conflict with git reset. Working-tree changes are still captured by the subsequent stash, so nothing is discarded — only the index-level conflict markers are dropped, letting the checkout proceed. Fixed in both installers for parity.

Reproduction

Leave the managed checkout with a conflicted index (e.g. an update interrupted mid-merge), then re-run the installer → git checkout main failed (exit 1). Reported by a Windows desktop user whose bootstrap-installer.log showed could not write index + you need to resolve your current index first across multiple retries.

Test plan

  • scripts/run_tests.sh tests/test_install_unmerged_index.py (3 passed)
  • Functional bash test drives install.sh's autostash block against a throwaway repo with a real conflicted index and asserts the stash now succeeds and the unmerged entries are cleared; source-order assertions ensure the git reset clear runs before git stash push in both scripts.

Infographic

Installer Update Recovery

xxxigm added 2 commits June 13, 2026 17:00
When an existing install at $INSTALL_DIR has an unmerged index (files in a
"needs merge" state left by a previously interrupted update), the update path
ran `git stash` then `git checkout <branch>`. On a conflicted index `git stash`
aborts with "could not write index" and `git checkout` then aborts with "you
need to resolve your current index first" — surfacing to desktop/bootstrap
users as `git checkout main failed (exit 1)` and failing the whole install at
the repository stage.

Mirror the `hermes update` Python path (NousResearch#4735): detect unmerged entries with
`git ls-files --unmerged` and clear the conflict state with `git reset` before
stashing. Working-tree changes are still captured by the subsequent stash, so
nothing is discarded; only the index-level conflict markers are dropped, which
lets the checkout proceed.

Fixed in both installers (install.sh and install.ps1) so the Windows GUI
installer and the POSIX one share the same recovery behavior.
Functional bash test drives install.sh's autostash block against a throwaway
repo with a real conflicted index and asserts the stash now succeeds and the
unmerged entries are cleared (previously `git stash` failed with "could not
write index"). Source-order assertions cover both scripts to ensure the
`git reset` clear runs before `git stash push` (a no-op otherwise).
@liuhao1024

Copy link
Copy Markdown
Contributor

Verified: clean.

Reviewed both install.sh and install.ps1 changes. The fix correctly detects unmerged index entries (git ls-files --unmerged) and clears them with git reset -q before git stash push, preserving working-tree changes while dropping conflict markers. Order is verified by the test (idx_unmerged < idx_stash). The install.ps1 path mirrors the same pattern with proper PowerShell null-checking. Test coverage is thorough: integration test creates a real conflict in a throwaway repo, plus ordering-contract tests for both script variants.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles labels Jun 13, 2026

@tonydwb tonydwb 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.

Code Review Summary

Verdict: Approved

Fixes an edge case in the installer update path: if the git index has unmerged entries (e.g., from a previous interrupted merge), git stash fails silently. Now clears the index with git checkout -- . before stashing.

Correctness: git checkout -- . is the standard way to unresolve unmerged entries. Using --quiet --no_refresh flags keeps it efficient. Test covers the unmerged-entry scenario.


Reviewed by Hermes Agent (cron batch)

@teknium1
teknium1 merged commit c814d3d into NousResearch:main Jun 13, 2026
28 checks passed
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #45589: #45589

Your commits were cherry-picked onto current main with authorship preserved, and the salvage PR passed CI before merge. Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants