{"record":{"id":"1d82acdb0b157649","repo":"sgl-project/sglang","slug":"apple-metal-shader-compiler-not-found-install-a-f","errorCode":null,"errorMessage":"Apple Metal shader compiler not found. Install a full Xcode (not just Command Line Tools) so that `xcrun -sdk macosx metal` is available, then retry.","messagePattern":"Apple Metal shader compiler not found\\. Install a full Xcode \\(not just Command Line Tools\\) so that `xcrun -sdk macosx metal` is available, then retry\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/aot/setup_metal.py","lineNumber":49,"sourceCode":"    (\"nanobind\", \"nanobind\"),\n]\n\n\ndef _ensure_toolchain():\n    if sys.platform != \"darwin\" or platform.machine() != \"arm64\":\n        raise SystemExit(\"setup_metal.py only supports macOS (Apple Silicon).\")\n    if shutil.which(\"c++\") is None or shutil.which(\"xcrun\") is None:\n        raise SystemExit(\n            \"Apple toolchain not found. Install the Xcode Command Line Tools \"\n            \"with `xcode-select --install` (or a full Xcode install) and retry.\"\n        )\n    try:\n        subprocess.check_output(\n            [\"xcrun\", \"-sdk\", \"macosx\", \"metal\", \"--version\"],\n            stderr=subprocess.STDOUT,\n        )\n    except (subprocess.CalledProcessError, FileNotFoundError) as exc:\n        raise SystemExit(\n            \"Apple Metal shader compiler not found. Install a full Xcode \"\n            \"(not just Command Line Tools) so that `xcrun -sdk macosx metal` \"\n            \"is available, then retry.\"\n        ) from exc\n\n\ndef _ensure_build_requires():\n    missing = []\n    for import_name, pip_name in _BUILD_REQUIRES:\n        try:\n            importlib.import_module(import_name)\n        except ImportError:\n            missing.append(pip_name)\n    if not missing:\n        return\n    print(\n        f\"[sgl-kernel:metal] installing build requirements: {missing}\",\n        flush=True,","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/aot/setup_metal.py#L31-L67","documentation":"Beyond CLT, the Metal build needs the actual Metal shader compiler, verified by running `xcrun -sdk macosx metal --version`. Command Line Tools alone do not ship it, so the script demands a full Xcode install when the probe fails.","triggerScenarios":"Running the Metal build with only Xcode CLT installed (no full Xcode), or with Xcode installed but its command-line components not yet finished installing/accepted.","commonSituations":"Minimal CI Macs with just CLT; freshly installed Xcode where first-launch license/components setup is incomplete; broken xcode-select developer dir.","solutions":["Install full Xcode from the App Store, launch it once to complete component installation, then retry","Confirm `xcrun -sdk macosx metal --version` succeeds in the build shell","Re-run sudo xcode-select -s /Applications/Xcode.app and accept the license with sudo xcodebuild -license accept"],"exampleFix":"# before\nxcode-select --install\npython setup_metal.py build_ext --inplace  # fails: Metal shader compiler not found\n# after\n# install full Xcode, then:\nsudo xcode-select -s /Applications/Xcode.app\npython setup_metal.py build_ext --inplace","handlingStrategy":"validation","validationCode":"subprocess.run(['xcrun','-sdk','macosx','metal','--version'], check=True, capture_output=True)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install full Xcode for metal builds","Launch Xcode once post-install"],"tags":["metal","build","xcode","shader-compiler","macos"],"backgroundTag":"missing-build-toolchain","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}