mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-19 20:49:33 +01:00
fix(macos): never run Apple's placeholder git, which opens the developer tools window
On a Mac without the developer tools, /usr/bin/git is a placeholder: running it, even as `git --version`, makes macOS open its "install the command line developer tools" window. The server asked "is git here?" exactly that way on the first page load (isGitAvailable() from renderIndexHtml), so a no-admin install on such a Mac ended with that window one second after the server started, and it would have come back at every start. Found on a new MacBook on 2026-11-06: the system log names the Codeman server as the parent of that git process. One gate now stands in front of every git the server starts (src/utils/git-availability.ts). On macOS it resolves git on the PATH itself; when that is the placeholder, `xcode-select -p` must name a developer folder that holds a git of its own. xcode-select only prints and never opens a window. Without the tools, git counts as absent and is never started: every caller gets the ENOENT it already answers with "git is not installed". A refusal is asked again after a minute, so installing the tools later needs no server restart for the git features, and isGitAvailable() no longer memoizes that one refusal. Gated: the clone and worktree runners, the Git panel's status and fetch, the update check and repository status, and Read My Mind's workspace signals. test/git-spawn-gate.test.ts covers the decision and scans src/ for a git spawn in a file that does not call the gate, with the reviewed list of sites pinned. Checked for real on macOS 27 (Command Line Tools) and on a Mac with Xcode: both resolve /usr/bin/git, find the tools and allow git, in 3 to 5 ms. The refusal itself is covered by the unit tests; it still needs a run on a Mac without the tools. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
84d5c8de52
commit
9b8531f3d2
10 files changed
+371
-1
No files matched your search
@@ -41,6 +41,7 @@ import { createRequire } from 'node:module';
|
||||
import { promisify } from 'node:util';
|
||||
import { EXEC_TIMEOUT_MS } from '../config/exec-timeout.js';
|
||||
import { gitNonInteractiveEnv, redactGitCredentials } from '../git-clone.js';
|
||||
import { gitSpawnAllowed } from '../utils/git-availability.js';
|
||||
import { getInstallInfo } from './self-update.js';
|
||||
import type { RepoIncomingCommit, RepoRemoteRole, RepoRemoteStatus, RepositoryStatusResult } from '../types/update.js';
|
||||
|
||||
@@ -242,6 +243,8 @@ interface GitResult {
|
||||
* spawn would block the event loop for the whole wait.
|
||||
*/
|
||||
async function runGit(args: string[], cwd: string, timeout = EXEC_TIMEOUT_MS): Promise<GitResult> {
|
||||
// Never Apple's placeholder git on a Mac without developer tools (utils/git-availability.ts).
|
||||
if (!gitSpawnAllowed()) return { ok: false, stdout: '', stderr: 'git is not installed' };
|
||||
try {
|
||||
const { stdout } = await execFileAsync('git', args, {
|
||||
cwd,
|
||||
|
||||
@@ -41,6 +41,7 @@ import { createRequire } from 'node:module';
|
||||
import { dataPath } from '../config/instance.js';
|
||||
import { LAUNCHD_LABEL, SYSTEMD_UNIT } from '../config/service-names.js';
|
||||
import { EXEC_TIMEOUT_MS } from '../config/exec-timeout.js';
|
||||
import { gitSpawnAllowed } from '../utils/git-availability.js';
|
||||
import type {
|
||||
EnvironmentBlocker,
|
||||
EnvironmentGate,
|
||||
@@ -429,6 +430,8 @@ export function reconcileUpdateOnBoot(now = Date.now()): void {
|
||||
|
||||
/** Run a command, returning trimmed stdout, or null on any error. */
|
||||
function tryExec(cmd: string, args: string[], cwd?: string, timeout = EXEC_TIMEOUT_MS): string | null {
|
||||
// Never Apple's placeholder git on a Mac without developer tools (utils/git-availability.ts).
|
||||
if (cmd === 'git' && !gitSpawnAllowed()) return null;
|
||||
try {
|
||||
return execFileSync(cmd, args, { cwd, encoding: 'utf-8', timeout, stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user