Skip to content

Existing hook-failure diagnostics are unnecessarily gated by shell-environment loading #23012

Open

Description

@molnarriso

The problem

GitHub Desktop already implements hook-specific failure reporting, including identifying the failing hook and displaying its output. However, this functionality is only available when “Load Git hook environment variables from shell” is enabled.

With that preference disabled, Desktop bypasses the existing hook proxy and its failure reporting. A preference about where environment variables come from therefore also controls whether users receive hook-specific diagnostics.

I encountered this while pushing a repository with a pre-push hook. Desktop displayed:

The operation timed out because a response was not received from the virtual machine or container.
Error code: Bash/Service/HCS_E_CONNECTION_TIMEOUT
error: failed to push some refs

The failure occurred while launching the hook, but the dialog did not identify pre-push as its source.

Expected: reuse the existing hook-failure reporting regardless of the shell-loading preference. No additional diagnostic mechanism or UI should be necessary; the existing functionality needs to be available in both modes.

Release version

3.6.6

Operating system

Windows 11 Pro 25H2

Steps to reproduce the behavior

  1. In Options → Git → Hooks, leave “Load Git hook environment variables from shell” unchecked.
  2. In a disposable test repository with a configured remote, create a failing pre-push hook:
    #!/bin/sh
    echo "Example hook failure" >&2
    exit 1
  3. Attempt to push using GitHub Desktop.
  4. Observe that the failure is reported through the generic push-error path rather than the existing hook-specific failure UI.

The simple hook above isolates the diagnostic gap from the Bash/WSL failure that originally exposed it.

Log files

No response

Screenshots

Image

Additional context

The relevant functionality already exists. In withHooksEnv, the shell-loading preference currently causes an early return before the hook proxy is created. This skips both shell-environment loading and the existing hook progress/failure callbacks.

PR #21319 introduced these capabilities together. They share infrastructure, but hook-failure diagnostics are useful whether the environment is inherited or loaded from a shell.

The proposed change is to reuse the same proxy, callbacks, and UI in both modes, while limiting the preference to selecting the environment source:

  • Enabled: load the shell environment as today.
  • Disabled: use the inherited Git environment, preserving configuration and credentials while removing Desktop’s temporary interception settings.

In the original failure, the hook used #!/usr/bin/env bash. Investigation found that Desktop’s environment resolved Bash to the Windows WSL launcher, whereas system Git resolved Git for Windows’ Bash. That explains the execution difference; this issue specifically concerns the missing hook attribution.

Proposed implementation: PR #23011

Activity

  1. desktop-triage commented on Oct 13, 2026

    @desktop-triage

    Triage: Suggesting bug + priority-3 (for maintainer approval). The report describes a diagnostics regression, not a feature request: Desktop's existing hook-failure UI (identifying the failing hook and its output) is silently skipped whenever "Load Git hook environment variables from shell" is disabled, even though hooks still run. I found no exact duplicate; related issues (#22476 "post-merge hook does not appear to run in UI", #22620 "pre-push hook fails due to /dev/stdin", #22701 "pre-commit hook hanging") describe different gaps (missing diagnostics for specific hook types, a Windows stdin bug, and a hang), not this shell-preference gating.

    Initial hypothesis: In with-hooks-env.ts at commit 9ca714359368121907dbc638436d90c775717c91, withHooksEnv starts with if (!opts?.interceptHooks || !getHooksEnvEnabled()) { return fn(opts?.env) }. This means that whenever the "load shell env" preference (getHooksEnvEnabled()) is off, the function returns early before the hooks proxy (createHooksProxy, lines 48–62) is ever constructed — the same proxy that wires up opts?.onHookProgress and opts?.onHookFailure callbacks responsible for the hook-specific failure dialog. Git still executes hooks directly in that mode, but Desktop has no interception point to attribute a failure to a specific hook, so the error surfaces through the generic command-failure path instead (consistent with the reporter's screenshot showing a generic push error with no pre-push attribution). This supports the reporter's proposed fix direction: decoupling proxy/callback creation from the shell-env-loading preference so hook-failure diagnostics work in both modes, while the preference only toggles the environment source used when hooks do run.

    Generated by Issue Triage (skills-driven) for #23012 · auto · 31.4 AIC · ⌖ 1.21 AIC · ⊞ 9K · ◷

  2. added
    bug
    priority-3
    on Oct 15, 2026
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

    bugpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions