{"record":{"id":"2eb3f8b6d2f374c1","repo":"rust-lang/rust","slug":"no-cargo-executable-found-at","errorCode":null,"errorMessage":"no cargo executable found at `{}`","messagePattern":"no cargo executable found at `(.+?)`","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/bootstrap/bootstrap.py","lineNumber":1150,"sourceCode":"\n        # If any of RUSTFLAGS or RUSTFLAGS_BOOTSTRAP are present and nonempty,\n        # we allow arbitrary compiler flags in there, including unstable ones\n        # such as `-Zthreads=8`.\n        #\n        # But if there aren't custom flags being passed to bootstrap, then we\n        # cancel the RUSTC_BOOTSTRAP=1 from above by passing `-Zallow-features=`\n        # to ensure unstable language or library features do not accidentally\n        # get introduced into bootstrap over time. Distros rely on being able to\n        # compile bootstrap with a variety of their toolchains, not necessarily\n        # the same as Rust's CI uses.\n        if env.get(\"RUSTFLAGS\", \"\") or env.get(\"RUSTFLAGS_BOOTSTRAP\", \"\"):\n            # Preserve existing RUSTFLAGS.\n            env.setdefault(\"RUSTFLAGS\", \"\")\n        else:\n            env[\"RUSTFLAGS\"] = \"-Zallow-features=\"\n\n        if not os.path.isfile(self.cargo()):\n            raise Exception(\"no cargo executable found at `{}`\".format(self.cargo()))\n        args = [\n            self.cargo(),\n            \"build\",\n            \"--jobs=\" + self.jobs,\n            \"--manifest-path\",\n            os.path.join(self.rust_root, \"src/bootstrap/Cargo.toml\"),\n            \"-Zroot-dir=\" + self.rust_root,\n        ]\n        # verbose cargo output is very noisy, so only enable it with -vv\n        args.extend(\"--verbose\" for _ in range(self.verbose - 1))\n        if self.verbose < 0:\n            args.append(\"--quiet\")\n\n        target_features = []\n        if self.get_toml(\"crt-static\", build_section) == \"true\":\n            target_features += [\"+crt-static\"]\n        elif self.get_toml(\"crt-static\", build_section) == \"false\":\n            target_features += [\"-crt-static\"]","sourceCodeStart":1132,"sourceCodeEnd":1168,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/bootstrap/bootstrap.py#L1132-L1168","documentation":"Raised by build_bootstrap() in bootstrap.py at line 1149-1150 when the resolved cargo executable path does not exist as a regular file. The path comes from self.cargo() (program_config), which returns either the 'build.cargo' toml value (expanded) or bin_root/bin/cargo(+.exe). Before invoking cargo to build the Rust bootstrap crate, the code verifies the binary exists.","triggerScenarios":"build_bootstrap() at line 1149: os.path.isfile(self.cargo()) returns False. self.cargo() resolves to either a user-configured build.cargo path in config.toml or the stage0-installed cargo under build_dir/<host>/stage0/bin/cargo. If the stage0 download/extraction failed silently, or build.cargo points to a non-existent path, this guard fires.","commonSituations":"The stage0 cargo was never downloaded (network failure upstream that didn't raise), an interrupted build left the bin_root incomplete, build.cargo in config.toml is set to a wrong path, EXE_SUFFIX mismatch on Windows (cargo vs cargo.exe), or the build directory was manually deleted/partially cleaned.","solutions":["Run 'x.py clean' to remove the partial build directory, then re-run to trigger a fresh stage0 download.","If build.cargo is set in config.toml, verify the path exists and is executable: 'ls -la <path>'.","Check that the stage0 download step completed successfully (look for earlier 'failed verification' or download errors).","On Windows, ensure the path includes the .exe suffix or that program_config resolves it correctly via EXE_SUFFIX."],"exampleFix":"# before: config.toml points at non-existent cargo\n[build]\ncargo = \"/wrong/path/cargo\"\n# after: remove the override to use stage0 cargo, or fix the path\n# (delete the line) or\ncargo = \"/home/user/.cargo/bin/cargo\"","handlingStrategy":"validation","validationCode":"# Before build_bootstrap, verify cargo exists\nimport os\ndef check_cargo(build):\n    cargo_path = build.cargo()\n    if not os.path.isfile(cargo_path):\n        print(f'ERROR: cargo not found at {cargo_path}')\n        print('Run x.py clean and retry to re-download stage0.')\n        return False\n    return True","typeGuard":null,"tryCatchPattern":"try:\n    build.build_bootstrap()\nexcept Exception as e:\n    if 'no cargo executable found' in str(e):\n        # stage0 incomplete — clean and retry\n        print('Stage0 cargo missing. Cleaning build dir and retrying...')\n        # user should run: x.py clean\n    raise","preventionTips":["Run 'x.py clean' after interrupted builds to ensure a complete stage0 re-download.","If setting build.cargo in config.toml, verify the path with 'ls -la' first.","On Windows, ensure EXE_SUFFIX handling resolves cargo.exe correctly.","Don't manually delete files from build_dir/stage0/bin/ — use x.py clean."],"tags":["bootstrap","rustc","cargo","stage0","path-resolution","python"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}