Skip to content

The agent that grows with you

fix(desktop): name the unlaunchable git instead of blaming the update server

teknium1107e6fc4af52
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 113f16b598e..d8a8141c447 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -389,7 +389,7 @@ import {
type SecretStoragePolicy,
writeSecretStoragePolicy
} from './secret-storage-policy'
-import { selectRunnableBinary } from './select-runnable-binary'
+import { describeGitSpawnFailure, GIT_UNUSABLE, selectRunnableBinary } from './select-runnable-binary'
import {
buildInstanceWindowUrl,
buildSessionWindowUrl,
@@ -3173,8 +3173,10 @@ function resolveUpdateRoot() {
function runGit(args, options: any = {}): Promise<{ code: number; stdout: string; stderr: string }> {
return new Promise((resolve, reject) => {
+ const gitBinary = resolveGitBinary()
+
const child = spawn(
- resolveGitBinary(),
+ gitBinary,
IS_WINDOWS ? ['-c', 'windows.appendAtomically=false', ...args] : args,
hiddenWindowsChildOptions({
cwd: options.cwd,
@@ -3195,7 +3197,13 @@ function runGit(args, options: any = {}): Promise<{ code: number; stdout: string
stderr += text
options.onLine?.('stderr', text)
})
- child.once('error', reject)
+ // A spawn-level failure means git itself never ran (missing, not
+ // executable, wrong CPU architecture) — a local problem, not a network one.
+ child.once('error', error => {
+ const local = describeGitSpawnFailure(error, gitBinary)
+
+ reject(local ? Object.assign(new Error(local), { kind: GIT_UNUSABLE, cause: error }) : error)
+ })
// 'close', not 'exit': exit can fire before the stdio pipes drain, and a
// resolved-early `remote get-url` came back as "" often enough to route
// passive checks down the wrong remote path.
@@ -17559,7 +17567,7 @@ ipcMain.handle('hermes:updates:check', async (_event, opts) =>
checkUpdates({ force: Boolean(opts?.force) }).catch(error => ({
supported: true,
branch: readDesktopUpdateConfig().branch,
- error: 'check-failed',
+ error: error?.kind === GIT_UNUSABLE ? GIT_UNUSABLE : 'check-failed',
message: error?.message || String(error),
fetchedAt: Date.now()
}))
diff --git a/apps/desktop/electron/select-runnable-binary.test.ts b/apps/desktop/electron/select-runnable-binary.test.ts
index 6552cd03d9c..cdc0df32027 100644
--- a/apps/desktop/electron/select-runnable-binary.test.ts
+++ b/apps/desktop/electron/select-runnable-binary.test.ts
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict'
import { test } from 'vitest'
-import { selectRunnableBinary } from './select-runnable-binary'
+import { describeGitSpawnFailure, selectRunnableBinary } from './select-runnable-binary'
const yes = () => true
const no = () => false
@@ -56,3 +56,27 @@ test('missing candidates are never probed, and nothing existing yields null for
assert.equal(selectRunnableBinary({ candidates: ['/opt/homebrew/bin/gh'], fileExists: no, binaryRuns: no }), null)
assert.equal(selectRunnableBinary({ candidates: [], fileExists: yes, binaryRuns: yes }), null)
})
+
+test.each([
+ {
+ // The reported machine: Darwin errno 86 (Bad CPU type) reaches Node as a
+ // bare `errno: -86` with no `code` — "spawn Unknown system error -86".
+ name: 'EBADARCH via errno -86 names the binary and the CPU-type cause',
+ error: { errno: -86, syscall: 'spawn', message: 'spawn Unknown system error -86' },
+ expected: /Git on this computer cannot run \(\/usr\/local\/bin\/git: Bad CPU type in executable\)/
+ },
+ {
+ name: 'ENOENT reads as a missing binary',
+ error: { code: 'ENOENT', errno: -2, syscall: 'spawn /usr/local/bin/git' },
+ expected: /\/usr\/local\/bin\/git: not found/
+ }
+])('$name', ({ error, expected }) => {
+ assert.match(describeGitSpawnFailure(error, '/usr/local/bin/git') ?? '', expected)
+})
+
+test('a git that ran and exited nonzero is not a spawn failure and keeps its own wording', () => {
+ // Nonzero exits never fire the child 'error' event; only spawn-level
+ // failures (binary missing / not executable / wrong architecture) do.
+ assert.equal(describeGitSpawnFailure(new Error('fatal: not a git repository'), '/usr/bin/git'), null)
+ assert.equal(describeGitSpawnFailure({ code: 'ETIMEDOUT' }, '/usr/bin/git'), null)
+})
diff --git a/apps/desktop/electron/select-runnable-binary.ts b/apps/desktop/electron/select-runnable-binary.ts
index ba526d3d9f8..beafb96a004 100644
--- a/apps/desktop/electron/select-runnable-binary.ts
+++ b/apps/desktop/electron/select-runnable-binary.ts
@@ -32,3 +32,39 @@ export function selectRunnableBinary(opts: RunnableBinaryOptions): string | null
return existing.find(opts.binaryRuns) || existing[0] || null
}
+
+/** Marker on the error runGit rejects with when the git binary itself could not be spawned. */
+export const GIT_UNUSABLE = 'git-unusable'
+
+const SPAWN_FAILURE_REASONS: Record<string, string> = {
+ ENOENT: 'not found',
+ EACCES: 'permission denied',
+ EBADARCH: 'Bad CPU type in executable'
+}
+
+/**
+ * Turn a child-process 'error' (the binary never ran, as opposed to running
+ * and exiting nonzero) into an actionable local-executable message.
+ *
+ * Without this the caller shows the update-server/network copy plus the raw
+ * `spawn Unknown system error -86` — a network claim for a local Intel-only
+ * git that macOS refuses to launch (EBADARCH is errno 86 on Darwin, surfaced by
+ * Node as errno -86 with no `code`). The message names the binary that failed
+ * so the user can replace it; nothing in this path is a network problem.
+ *
+ * Returns null for anything that is not a spawn-level failure so those keep
+ * their existing wording.
+ */
+export function describeGitSpawnFailure(error: any, binaryPath: string): string | null {
+ const code = error?.code || (error?.errno === -86 ? 'EBADARCH' : '')
+ const reason = SPAWN_FAILURE_REASONS[code]
+
+ if (!reason) {
+ return null
+ }
+
+ return (
+ `Git on this computer cannot run (${binaryPath}: ${reason}). ` +
+ 'Install a Git build for this machine (on macOS: `xcode-select --install`) and check again.'
+ )
+}
diff --git a/apps/desktop/src/app/settings/about-settings.tsx b/apps/desktop/src/app/settings/about-settings.tsx
index 81f797078ce..5d84d65e283 100644
--- a/apps/desktop/src/app/settings/about-settings.tsx
+++ b/apps/desktop/src/app/settings/about-settings.tsx
@@ -83,7 +83,9 @@ export function AboutSettings() {
statusLine = status?.message ?? a.cantUpdate
statusTone = 'error'
} else if (status?.error) {
- statusLine = status.message ? `${a.cantReach} ${status.message}` : a.cantReach
+ // A git that never ran is a local problem; leading with "couldn't reach
+ // the update server" would misdiagnose it as a network failure.
+ statusLine = [status.error === 'git-unusable' ? '' : a.cantReach, status.message].filter(Boolean).join(' ')
statusTone = 'error'
} else if (applying) {
statusLine = a.installing
diff --git a/apps/desktop/src/app/updates-overlay.tsx b/apps/desktop/src/app/updates-overlay.tsx
index 4fc09791439..1fa5372b012 100644
--- a/apps/desktop/src/app/updates-overlay.tsx
+++ b/apps/desktop/src/app/updates-overlay.tsx
@@ -247,7 +247,7 @@ function IdleView({
)}
</div>
}
- body={u.connectionRetry}
+ body={status.error === 'git-unusable' ? u.gitUnusable : u.connectionRetry}
detail={status.message}
icon={<ErrorIcon />}
title={u.checkFailedTitle}
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index fc86affe0bd..9a9161fc79b 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -2377,6 +2377,7 @@ export const ar = defineLocale({
notAvailableTitle: 'التحديث غير متاح',
unsupportedMessage: 'لا يمكن لهذا الإصدار من Hermes تحديث نفسه من داخل التطبيق.',
connectionRetry: 'تحقق من اتصالك وأعد المحاولة.',
+ gitUnusable: 'لم يتمكن Hermes من تشغيل Git على هذا الجهاز، لذا لم يتمكن من التحقق من التحديثات.',
latestBody: 'أنت تستخدم أحدث إصدار.',
latestBodyBackend: 'الواجهة الخلفية تعمل بأحدث إصدار.',
allSetTitle: 'كل شيء جاهز',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 8a2be3d729f..749ea18fdec 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -3294,6 +3294,7 @@ export const en: Translations = {
unsupportedMessage: 'This version of Hermes can’t update itself from inside the app.',
connectionRetry:
"Hermes couldn't reach the update server. Check your internet connection and try again. If you use a remote Hermes, make sure it is online.",
+ gitUnusable: 'Hermes could not run Git on this computer, so it could not check for updates.',
connectionSettings: 'Connection settings',
openDownloadPage: 'Open download page',
latestBody: 'You’re running the latest version.',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index a3012935e68..a2eec2699df 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -2743,6 +2743,7 @@ export const ja = defineLocale({
notAvailableTitle: '更新は利用できません',
unsupportedMessage: 'このバージョンの Hermes はアプリ内から自分を更新できません。',
connectionRetry: '接続を確認してもう一度試してください。',
+ gitUnusable: 'このコンピューターで Git を実行できなかったため、更新を確認できませんでした。',
latestBody: '最新バージョンを実行しています。',
latestBodyBackend: 'バックエンドは最新バージョンを実行しています。',
allSetTitle: '準備完了',
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index 7a2a4861376..a9525d71b88 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -3054,6 +3054,7 @@ export const ru = defineLocale({
notAvailableTitle: 'Обновление недоступно',
unsupportedMessage: 'Эта версия Hermes не может обновлять себя из приложения.',
connectionRetry: 'Проверьте соединение и попробуйте снова.',
+ gitUnusable: 'Hermes не удалось запустить Git на этом компьютере, поэтому проверить обновления не получилось.',
latestBody: 'У вас последняя версия.',
latestBodyBackend: 'Бэкенд работает на последней версии.',
allSetTitle: 'Всё готово',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index e140e76fc8a..1a060abd37d 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -2844,6 +2844,7 @@ export interface Translations {
notAvailableTitle: string
unsupportedMessage: string
connectionRetry: string
+ gitUnusable: string
connectionSettings: string
openDownloadPage: string
latestBody: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index 1cfe317a7cd..6e45174100a 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -2724,6 +2724,7 @@ export const zhHant = defineLocale({
notAvailableTitle: '更新不可用',
unsupportedMessage: '此版本的 Hermes 無法在應用程式內自行更新。',
connectionRetry: '請檢查網路連線後重試。',
+ gitUnusable: 'Hermes 無法在這台電腦上執行 Git,因此無法檢查更新。',
latestBody: '您正在執行最新版本。',
latestBodyBackend: '後端正在執行最新版本。',
allSetTitle: '已是最新版本',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index bffb22edadc..86a686272c4 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -3429,6 +3429,7 @@ export const zh = defineLocale({
notAvailableTitle: '更新不可用',
unsupportedMessage: '此版本的 Hermes 无法在应用内自行更新。',
connectionRetry: '请检查网络连接后重试。',
+ gitUnusable: 'Hermes 无法在这台电脑上运行 Git,因此无法检查更新。',
latestBody: '你正在运行最新版本。',
latestBodyBackend: '后端正在运行最新版本。',
allSetTitle: '已是最新',