Skip to content

Without git on PATH the app crashes at startup and when a cloned repo is selected, and clone/fetch/pull fail without a log line #520

Open

Description

@matt-edmondson

What's wrong

GitCli.Run (ProjectDirector/GitCli.cs ~L107) calls RunCommand.Execute("git", arguments, handler) without any guard. The synchronous Execute in ktsu.RunCommand blocks on ExecuteAsync(...).Result, and process.Start() isn't caught there. So when the git executable can't be found, GitCli.Run throws an AggregateException wrapping a Win32Exception, where it should return a failed GitResult. Nothing in ProjectDirector catches either type.

Why it matters

This is a realistic setup for the app's users: GitHub Desktop bundles its own git and doesn't put it on PATH, and the app has an "Open in GHD" button.

  • Startup: the constructor calls RefreshPage() (ProjectDirector.cs ~L140, ~L837–843), which calls UpdateClonedStatus and then GitCli.IsRepository. For any repo whose clone directory exists, git is run and throws. Once a cloned repo is saved in settings, the app can't start until someone edits the settings JSON by hand.
  • Selecting a repo: SwitchPage(baseRepo) (~L670–679) calls UpdateClonedStatus on the render thread and crashes. Scan > Dev Dir crashes the same way (~L1342).
  • Background work:
    • Fetch (~L494), pull (~L552), commit and push run as bare Tasks, so the exception goes unobserved and nothing reaches the git log. Auto-fetch fails silently every minute.
    • Clone runs through CloneTracker.TryRun, whose finally only re-enables the button.
    • The sibling comparison's catch filter (~L1517: IOException/UnauthorizedAccessException/InvalidOperationException/ArgumentException) doesn't match AggregateException, so Similar Repos stays on "Comparing repositories..." for good.

Suggested fix

  • In GitCli.Run, catch Win32Exception, including one wrapped in an AggregateException. Return a failed GitResult, for example exit code -1 with the error "git was not found on PATH; install Git or add it to PATH".
  • Callers already handle !Succeeded, so clone, fetch and pull would then report the failure through QueueGitLog, and IsRepository would return false instead of throwing.
  • Optionally, run git --version once at startup and log the same message.

Acceptance criteria

  • A test that points PATH at an empty directory and asserts that GitCli.Run("--version") returns a failed result with an explanatory error instead of throwing.
  • Starting the app with a cloned repo in settings and no git on PATH doesn't crash, and the git log explains the problem.

Not the same as #466 (launching github/explorer) or #519 (git prompting for credentials).

Activity

  1. matt-edmondson commented on Oct 31, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions