Expand description
Keep AFT from running Apple’s developer-tool shims on a Mac without them.
On macOS, /usr/bin/git (and clangd, sourcekit-lsp, python3, make,
xcrun, …) is not the tool itself but a small launcher linked against
/usr/lib/libxcselect.dylib. The launcher looks up the active developer
directory and runs the real tool from it. When no developer directory is
installed it prints “xcode-select: note: No developer tools were found,
requesting install” and opens the “Install Command Line Developer Tools”
dialog in the user’s GUI session, once per invocation. So AFT must never
spawn a launcher on such a machine, not even with --version.
The launcher’s lookup order is documented in xcode-select(1): the
DEVELOPER_DIR environment variable overrides everything; otherwise the
system-wide selection written by xcode-select --switch (the
/var/db/xcode_select_link symlink) is used; with no selection the
defaults are /Applications/Xcode.app/Contents/Developer and then
/Library/Developer/CommandLineTools. xcode-select -p reports that same
state and is safe (with no tools it prints an error and exits non-zero,
without the dialog). Reading those directories answers the common case
without spawning anything, so this module does that first and asks
xcode-select -p only when no known directory holds the tools.
The decision is made once per process. Only a launcher is ever refused: a user whose PATH finds a real git first (Homebrew, MacPorts, Nix) keeps every git feature even without the Xcode tools.
Structs§
- Detector
- Inputs to the launcher decision, separated from the process so tests can inject a “no developer tools” machine and a fake launcher directory.
- Developer
DirProbe - Where the launcher looks for a developer directory, in its own order.
Enums§
- GitAvailability
- Whether AFT may run
gitin this process.
Constants§
- MISSING_
DEVELOPER_ TOOLS_ REASON - The user-facing explanation shown by status when git features are off.
Functions§
- git_
availability - The once-per-process git decision. Logs once when git is turned off.
- git_
status_ json - Status payload describing whether git features are on.
- git_
usable - Whether engine code may spawn
git. A disabled tool cannot determine whether a directory is a repository or which index data belongs to it. Preserve that uncertainty rather than using it to choose another identity or delete data. - is_
unusable_ launcher - Whether a resolved tool path (LSP server, formatter) is an Apple launcher that must not run on this machine. Callers treat it as not installed.
- macos_
developer_ tools_ present - Follow the launcher’s lookup order without running anything.