{"record":{"id":"7f02264f2750b7a2","repo":"rust-lang/rust","slug":"failed-to-locate-libstd-in-rustlibs-dir","errorCode":null,"errorMessage":"Failed to locate libstd (in {rustlibs_dir})","messagePattern":"Failed to locate libstd \\(in (.+?)\\)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"src/ci/docker/scripts/fuchsia-test-runner.py","lineNumber":692,"sourceCode":"        Args:\n        args: The command-line arguments to this command.\n        Returns:\n        The return code of the test (0 for success, else failure).\n\n        To run a test, this function will:\n        - Create, compile, archive, and publish a test package\n        - Run the test package on the emulator\n        - Forward the test's stdout and stderr as this script's stdout and stderr\n        \"\"\"\n\n        bin_path = Path(args.bin_path).absolute()\n\n        # Find libstd and libtest\n        libstd_paths = glob.glob(os.path.join(self.rustlibs_dir(), \"libstd-*.so\"))\n        libtest_paths = glob.glob(os.path.join(self.rustlibs_dir(), \"libtest-*.so\"))\n\n        if not libstd_paths:\n            raise Exception(f\"Failed to locate libstd (in {self.rustlibs_dir()})\")\n\n        base_name = os.path.basename(os.path.dirname(args.bin_path))\n        exe_name = base_name.lower().replace(\".\", \"_\")\n        build_id = self.build_id(bin_path)\n        package_name = f\"{exe_name}_{build_id}\"\n\n        package_dir = self.packages_dir.joinpath(package_name)\n        package_dir.mkdir(parents=True, exist_ok=True)\n        meta_dir = package_dir.joinpath(\"meta\")\n        meta_dir.mkdir(parents=True, exist_ok=True)\n        meta_package_path = meta_dir.joinpath(\"package\")\n        cml_path = meta_dir.joinpath(f\"{package_name}.cml\")\n        cm_path = meta_dir.joinpath(f\"{package_name}.cm\")\n        manifest_path = package_dir.joinpath(f\"{package_name}.manifest\")\n\n        shared_libs = args.shared_libs[: args.n]\n        arguments = args.shared_libs[args.n :]\n","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/ci/docker/scripts/fuchsia-test-runner.py#L674-L710","documentation":"Raised by TestEnvironment.run() when glob.glob for libstd-*.so in rustlibs_dir() returns nothing. libstd is a required shared library that must be packaged alongside the test binary on Fuchsia (see MANIFEST_TEMPLATE at line 657). Its absence means the Rust build did not produce the expected target libraries.","triggerScenarios":"The 'run' subcommand is invoked (fuchsia-test-runner.py:691) and glob at line 688 finds zero files matching {rust_build_dir}/host/stage2/lib/rustlib/{target}/lib/libstd-*.so.","commonSituations":"The Rust build was not completed to stage2 for the Fuchsia target; --rust-build passed to 'start' points at the wrong build directory; --target does not match the triple actually built; only a host build exists without the target's rustlib; the build used static libstd so no .so was emitted (schema/build-system change).","solutions":["Confirm the file exists: `ls {rust_build_dir}/host/stage2/lib/rustlib/{target}/lib/libstd-*.so`.","Complete the Rust build for the Fuchsia target up to stage2 (e.g. `x.py build --stage 2 library` with the right target).","Verify the --rust-build and --target values given to 'start' match the actual build output layout.","If libstd is now statically linked for this target, update the runner to treat libstd as optional (as was already done for libtest at lines 798-803)."],"exampleFix":"// before\n$ fuchsia-test-runner.py run <n> <bin> <libs...>\n# Exception: Failed to locate libstd (in .../host/stage2/lib/rustlib/aarch64-unknown-fuchsia/lib)\n\n// after - build stage2 for the target first\n$ ./x.py build --stage 2 --target aarch64-unknown-fuchsia library\n$ fuchsia-test-runner.py run <n> <bin> <libs...>","handlingStrategy":"validation","validationCode":"import glob, os\n\nrustlibs = os.path.join(rust_build_dir, \"host\", \"stage2\", \"lib\", \"rustlib\", target, \"lib\")\nlibstd = glob.glob(os.path.join(rustlibs, \"libstd-*.so\"))\nif not libstd:\n    raise SystemExit(\n        f\"libstd-*.so not found in {rustlibs}; build stage2 for {target} first \"\n        \"(`./x.py build --stage 2 --target <t> library`).\"\n    )\n# safe to call run()\nenv.run(args)","typeGuard":"null","tryCatchPattern":"try:\n    test_env.run(args)\nexcept Exception as e:\n    if \"Failed to locate libstd\" in str(e):\n        logging.error(\"Rust build incomplete for target %s; run x.py build --stage 2.\", env.target)\n    raise","preventionTips":["Always complete `x.py build --stage 2 --target <fuchsia-triple> library` before invoking 'run'.","Verify the --rust-build and --target passed to 'start' match the actual build layout.","In CI, gate the Fuchsia test job on the libstd-*.so glob succeeding."],"tags":["fuchsia","libstd","rust-build","glob","stage2"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}