{"record":{"id":"3a54607f94de109f","repo":"sgl-project/sglang","slug":"metal-shader-source-not-found-metal-src","errorCode":null,"errorMessage":"metal shader source not found: {metal_src}","messagePattern":"metal shader source not found: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/aot/setup_metal.py","lineNumber":184,"sourceCode":"            nanobind_dir / \"include\",\n            nanobind_dir / \"ext\" / \"robin_map\" / \"include\",\n            mlx_include,\n            mlx_include / \"metal_cpp\",\n        ]\n        all_includes = ext_include_dirs + host_includes\n        include_args = [f\"-I{p}\" for p in all_includes]\n        # `xcrun metal` accepts `-I` for header search; reuse the project\n        # include dirs so shaders can include shared MSL headers.\n        metal_include_args = [f\"-I{p}\" for p in ext_include_dirs]\n\n        if not metal_shader_sources:\n            raise RuntimeError(\"metal_shader_sources is empty; nothing to compile\")\n\n        air_paths = []\n        for rel in metal_shader_sources:\n            metal_src = root / rel\n            if not metal_src.is_file():\n                raise RuntimeError(f\"metal shader source not found: {metal_src}\")\n            air_path = generated_dir / (metal_src.stem + \".air\")\n            self.spawn(\n                [\n                    \"xcrun\",\n                    \"-sdk\",\n                    \"macosx\",\n                    \"metal\",\n                    f\"-std={metal_std}\",\n                    *metal_flags,\n                    *metal_include_args,\n                    \"-c\",\n                    str(metal_src),\n                    \"-o\",\n                    str(air_path),\n                ]\n            )\n            air_paths.append(str(air_path))\n","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/aot/setup_metal.py#L166-L202","documentation":"Each entry in metal_shader_sources is resolved to a file under the project root and must exist before `xcrun metal` compiles it. A listed-but-missing .metal file raises with the offending path.","triggerScenarios":"metal_shader_sources references a renamed/moved/deleted .metal file (stale list, hardcoded names, or glob evaluated from the wrong root), so metal_src.is_file() is False.","commonSituations":"Shader renames in a newer commit while a cached/hardcoded source list is reused; building from a subdirectory so root-relative paths miss; sparse checkouts missing files.","solutions":["Verify the printed path exists; update the source list/glob to the new filename or directory","Build from the repo root so Path(__file__).parent-relative resolution matches","Clean cached build state (build/ dir) after shader renames"],"exampleFix":"# before\nmetal_shader_sources = ['csrc/metal/rope_old.metal']\n# after\nmetal_shader_sources = ['csrc/metal/rope.metal']  # matches current file","handlingStrategy":"validation","validationCode":"assert all((root/rel).is_file() for rel in metal_shader_sources)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate shader lists after renames","Pin builds to known commits"],"tags":["metal","build","file-not-found","shader"],"backgroundTag":"missing-build-source-file","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}