Repository navigation
Stop the installer raising the macOS command line developer tools dialog - #8478
danielhanchen wants to merge 1 commit into
Conversation
On a Mac without the Command Line Tools, /usr/bin/git, lipo, install_name_tool and friends are libxcselect shims. Executing one resolves no developer dir and posts to com.apple.dt.CommandLineTools.installondemand, which draws the 'requires the command line developer tools' dialog naming the tool. Resolving the path does not; only execution does. Two call sites execute a shim on the consumer path: _has_working_git ran 'git --version' to decide whether git works, so on a clean Mac the probe raised the dialog it exists to detect. It now answers from the resolved path when that path is exactly /usr/bin/git and no toolchain is selected. Deliberately narrow: a Homebrew, MacPorts or Xcode.app git earlier on PATH is a real binary and is still probed by executing it, so a Mac with a working git but no CLT selected behaves exactly as before. An earlier version of this gated on 'no CLT implies no working git' and broke that case, which the existing test caught. xcode-select -p only asks which toolchain is selected and never prompts. The venv arch probe called lipo first and fell back to file -L. lipo is a shim; 2>/dev/null hides its stderr but not a GUI dialog. file is base system and always answers, so the order is swapped. Both spellings feed the same case below, against 'Mach-O 64-bit executable arm64' or 'universal binary ... [x86_64] [arm64]' rather than lipo's 'arm64' / 'x86_64 arm64', so the branch taken is unchanged. clean-machine-assert.sh already made this same swap for its own use. The cctools binaries were missing from the clean machine CI tool list, so none of this was visible: trace mode generated no wrapper and the absent list never checked them. install_name_tool, lipo, otool, objdump, vtool, strip and nm are added, which is what makes these fixes regression testable. test_macos_clt_gate.sh gains two cases pinning the contract: with a shim git and no toolchain selected the probe answers no WITHOUT executing it, proven by a stub that records execution into a marker file, and with a real git elsewhere on PATH the stub IS executed. The first assertion passed vacuously when written (wrong temp path meant the marker could never be created) and was fixed by making its pair fail first. 18 to 23 passing.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: feb85dd190
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| TOOLS="xcode-select xcrun clang clang++ cc c++ gcc g++ git cmake make brew ninja cargo rustc | ||
| install_name_tool lipo otool objdump vtool strip nm" |
There was a problem hiding this comment.
Avoid failing the trace row on uv's known relocation call
In the nonexperimental macos-15 trace row of .github/workflows/clean-machine-install-ci.yml, the installer creates an explicit uv-managed CPython and then runs clean-machine-assert.sh notools; adding install_name_tool here wraps and records the macOS relocation call that this change itself identifies as still being made by uv. Since notools treats every recorded tool except read-only xcode-select as a failure and this row does not allowlist install_name_tool, a fresh runner that downloads managed CPython will fail the required post-install assertion even though the installation succeeds. Either eliminate that invocation first or account for the known upstream call without making this required trace job permanently red.
Useful? React with 👍 / 👎.
| [ "$(command -v git)" = "${_CLT_GIT_SHIM:-/usr/bin/git}" ] && | ||
| ! xcode-select -p >/dev/null 2>&1; then |
There was a problem hiding this comment.
Probe Intel's real /usr/bin/git before rejecting it
On the supported Intel macOS configuration, /usr/bin/git can be a functional non-CLT binary even while xcode-select -p fails—the repository's clean-machine workflow and assertion explicitly document and allow this on macos-15-intel. This path-only check nevertheless classifies it as the CLT shim and returns without executing it, so a --local install on such an Intel Mac incorrectly reports that git is unavailable and demands the Command Line Tools despite already having working git.
Useful? React with 👍 / 👎.
|
Superseded by #8479. I cherry-picked |
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
The problem
On a Mac that has never had the Xcode Command Line Tools installed,
/usr/bin/git,lipo,install_name_tool,clangand around 90 others are not real binaries. They are libxcselect shims: each callsxcselect_invoke_xcrun, and when no developer dir resolves it posts tocom.apple.dt.CommandLineTools.installondemandover a CFMessagePort in the GUI session, which draws the "requires the command line developer tools" dialog naming the tool.The dialog needs the shim to be executed. Resolving its path does not fire it, which is why
command -v gitis both safe and useless:/usr/bin/gitexists on every Mac whether or not the tools are installed.Users installing on a fresh Mac are getting that dialog.
What this fixes
Two places on the consumer path execute a shim.
_has_working_gitrangit --versionto decide whether git works, so on a clean Mac the probe raised the dialog it exists to detect. It now answers from the resolved path when that path is exactly/usr/bin/gitand no toolchain is selected.Deliberately narrow. A Homebrew, MacPorts or Xcode.app git earlier on PATH is a real binary and is still probed by executing it, so a Mac with a working git but no CLT selected behaves exactly as before. An earlier version of this gated on "no CLT implies no working git" and broke that case;
tests/sh/test_macos_clt_gate.shcaught it.xcode-select -ponly asks which toolchain is selected and never prompts (it is absent from its own man page's shim list), which is the same idiom Homebrew, Salt, Chef, MacPorts and nvm all use.The venv arch probe called
lipofirst, falling back tofile -L.lipois a shim, and2>/dev/nullhides its stderr but not a GUI dialog.fileis base system and always answers, so the order is swapped. Both spellings feed the samecasebelow, matchingMach-O 64-bit executable arm64oruniversal binary ... [x86_64] [arm64]againstlipo'sarm64/x86_64 arm64, so the branch taken is unchanged.clean-machine-assert.sh:152already made exactly this swap for its own use.Why CI never caught it
The cctools binaries were missing from
clean-machine-env.sh'sTOOLSlist, so trace mode generated no wrapper for them and the absent list never checked them.install_name_tool,lipo,otool,objdump,vtool,stripandnmare added, which is what makes any of this regression testable.tests/sh/test_macos_clt_gate.shgains two cases pinning the contract:The first assertion passed vacuously when written (a wrong temp path meant the marker could never be created) and was corrected by making its pair fail first. 18 to 23 passing.
The remaining source, which this PR does not fix
The dialog most users actually see comes from
uv, not from this repo.install_name_toolappears nowhere in our tree.uv shells out to a bare
install_name_toolto fix the managed CPython dylib's install name (crates/uv-python/src/macos_dylib.rs), reached frominstallation.rson any automatic managed-Python download. Two aggravating details:install.shpasses--python-preference only-managedto stop uv executing the/usr/bin/python3shim, but that forces the managed CPython download, which is exactly what triggersinstall_name_tool. The existing mitigation makes the dialog more likely, not less.uv python installiteratesdownloaded.chain(satisfied), so it re-invokesinstall_name_toolon already-installed interpreters. The dialog recurs rather than appearing once.Upstream is aware and unfixed: astral-sh/uv#14843 is open, and astral-sh/uv#14893 ("Provide a way to skip install_name_tool invocation?") was filed by the Anki developer with the identical bundled-uv symptom. The proposed
xcode-select -pguard is unmerged, and PR #14869 is unmerged too.There is no supported way to silence it from our side.
XCODE_SELECT_NO_PROMPTanddefaults writekeys do not exist, in the man page, inlibxcselect.dylib's symbols, or anywhere else. The two real options, both larger than this PR and worth deciding separately:UV_NO_MANAGED_PYTHON=1. Removes the call by construction and is robust to uv changing internals. Costs bundle size and we own Python updates.DEVELOPER_DIRto a sentinel only oncexcode-select -phas already failed, converting the dialog into a silent non-zero exit. Cheap, but it rests on undocumentedwas_defaultgating and turns a visible prompt into a silent failure.Note that CI can verify the call never happens (trace mode, now wired up) but cannot verify the dialog itself, which needs a GUI bootstrap namespace a headless runner does not have.