{"record":{"id":"9af87bd6a064a23f","repo":"astral-sh/ruff","slug":"could-not-find-mdtest-executable-after-successful","errorCode":null,"errorMessage":"Could not find mdtest executable after successful compilation","messagePattern":"Could not find mdtest executable after successful compilation","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"crates/ty_python_semantic/mdtest.py","lineNumber":129,"sourceCode":"\n            if json_output:\n                self._get_executable_path_from_json(json_output)\n\n        if message_on_success:\n            self.console.print(\"[dim]Tests compiled successfully[/dim]\")\n        return True\n\n    def _get_executable_path_from_json(self, json_output: str) -> None:\n        for json_line in json_output.splitlines()[::-1]:\n            try:\n                data = json.loads(json_line)\n            except json.JSONDecodeError:\n                continue\n            if data.get(\"target\", {}).get(\"name\") == \"mdtest\" and data[\"executable\"]:\n                self.mdtest_executable = Path(data[\"executable\"])\n                break\n        else:\n            raise RuntimeError(\n                \"Could not find mdtest executable after successful compilation\"\n            )\n\n    def _run_mdtest(\n        self, arguments: list[str] | None = None, *, capture_output: bool = False\n    ) -> subprocess.CompletedProcess:\n        assert self.mdtest_executable is not None\n\n        arguments = arguments or []\n        return subprocess.run(\n            [self.mdtest_executable, *arguments],\n            cwd=CRATE_ROOT,\n            env=dict(\n                os.environ,\n                CLICOLOR_FORCE=\"1\",\n                INSTA_FORCE_PASS=\"1\",\n                INSTA_OUTPUT=\"none\",\n                MDTEST_EXTERNAL=\"1\" if self.enable_external else \"0\",","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/astral-sh/ruff/blob/d1087a4b9e03d253a88703f34e0869ee4b805456/crates/ty_python_semantic/mdtest.py#L111-L147","documentation":"mdtest.py is the Python harness wrapping ty_python_semantic's markdown test suite. It compiles the 'mdtest' test target with 'cargo test --package ty_python_semantic --no-run --test=mdtest --message-format=json', then scans cargo's JSON output from the end for a message whose target name is 'mdtest' with a non-null 'executable' path. This RuntimeError means cargo reported a successful build but no such message was found, so the harness cannot locate the test binary to run.","triggerScenarios":"The test target named 'mdtest' was renamed or removed from crates/ty_python_semantic/Cargo.toml; a cargo wrapper, alias, or toolchain configuration altered or suppressed the JSON compiler-artifact messages the script parses.","commonSituations":"After renaming the mdtest test target; unusual cargo setups (sccache-style wrappers, custom CARGO wrappers on PATH) that change message emission; cargo version behavior changes around --message-format=json.","solutions":["Verify the test target is still named 'mdtest' in crates/ty_python_semantic/Cargo.toml.","Force recompilation so cargo re-emits artifact messages: cargo clean -p ty_python_semantic, then rerun the script.","Bypass the wrapper and run the harness directly: cargo nextest run -p ty_python_semantic --test mdtest (or cargo test -p ty_python_semantic --test mdtest).","If you use a cargo alias/wrapper, run the script with a stock cargo first on PATH."],"exampleFix":"# before\npython crates/ty_python_semantic/mdtest.py   # RuntimeError: Could not find mdtest executable after successful compilation\n\n# after\ncargo clean -p ty_python_semantic\npython crates/ty_python_semantic/mdtest.py\n# or run the same binary without the wrapper:\ncargo nextest run -p ty_python_semantic --test mdtest","handlingStrategy":"try-catch","validationCode":"import json, subprocess\n\nmeta = json.loads(subprocess.check_output(\n    ['cargo', 'metadata', '--no-deps'], text=True\n))\ntargets = [\n    t['name']\n    for pkg in meta['packages']\n    if pkg['name'] == 'ty_python_semantic'\n    for t in pkg['targets']\n]\nassert 'mdtest' in targets, 'mdtest test target missing from ty_python_semantic'","typeGuard":null,"tryCatchPattern":"try:\n    wrapper.run()\nexcept RuntimeError as e:\n    if 'mdtest executable' in str(e):\n        subprocess.run([\n            'cargo', 'test', '-p', 'ty_python_semantic',\n            '--test', 'mdtest', '--nocapture',\n        ])\n    else:\n        raise","preventionTips":["Run the mdtest wrapper with a stock cargo on PATH (no aliases/wrappers).","If you rename the mdtest target, update mdtest.py expectations in the same commit.","Fall back to cargo nextest ... --test mdtest when the wrapper misbehaves; it drives the same binary."],"tags":["mdtest","cargo","testing","ty","python-tooling"],"backgroundTag":"build-artifact-lookup-failed","analyzedSha":"d1087a4b9e03d253a88703f34e0869ee4b805456","analyzedAt":"2026-08-20T16:33:49.445Z","contentChangedAt":"2026-08-20T16:33:49.445Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}