{"record":{"id":"3c3fd9ecbcb7a92b","repo":"rust-lang/rust","slug":"package-not-found-name","errorCode":null,"errorMessage":"package not found: {name}","messagePattern":"package not found: (.+?)","errorType":"validation","errorClass":"NameError","httpStatus":null,"severity":"error","filePath":"src/ci/docker/scripts/android-sdk-manager.py","lineNumber":123,"sourceCode":"    packages = {}\n    for repo in REPOSITORIES:\n        packages.update(fetch_repository(BASE_REPOSITORY, repo))\n    return packages\n\n\nclass Lockfile:\n    def __init__(self, path):\n        self.path = path\n        self.packages = {}\n        if os.path.exists(path):\n            with open(path) as f:\n                for line in f:\n                    path, url, sha1 = line.split(\" \")\n                    self.packages[path] = Package(path, url, sha1)\n\n    def add(self, packages, name, *, update=True):\n        if name not in packages:\n            raise NameError(\"package not found: \" + name)\n        if not update and name in self.packages:\n            return\n        self.packages[name] = packages[name]\n        for dep in packages[name].deps:\n            self.add(packages, dep, update=False)\n\n    def save(self):\n        packages = list(sorted(self.packages.values(), key=lambda p: p.path))\n        with open(self.path, \"w\") as f:\n            for package in packages:\n                f.write(package.path + \" \" + package.url + \" \" + package.sha1 + \"\\n\")\n\n\ndef cli_add_to_lockfile(args):\n    lockfile = Lockfile(args.lockfile)\n    packages = fetch_repositories()\n    for package in args.packages:\n        lockfile.add(packages, package)","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/ci/docker/scripts/android-sdk-manager.py#L105-L141","documentation":"Raised by Lockfile.add() in android-sdk-manager.py at line 123 as a NameError when the requested package name is not found in the packages dict (which is populated by fetching and parsing Google's SDK repository XML files). The add() function is called when adding packages to the lockfile or resolving dependencies; if the name doesn't match any package path in any of the REPOSITORIES, it cannot proceed.","triggerScenarios":"Lockfile.add(packages, name) at line 121-123: 'if name not in packages' is True. The packages dict is built by fetch_repositories() which fetches BASE_REPOSITORY + each URL in REPOSITORIES, parses the XML, and maps path -> Package. The name argument must exactly match a 'path' attribute from a <remotePackage> element in one of those XMLs.","commonSituations":"Typo or incorrect package path format (e.g. using a human-readable name instead of the dotted path like 'platforms;android-33'); the package was removed or renamed by Google; the repository XML that contains the package wasn't fetched (e.g. only a subset of REPOSITORIES were queried); or using a package path format with wrong delimiters.","solutions":["List available packages by running the official 'sdkmanager --list' or by inspecting the repository XMLs to find the exact path string.","Correct the package name to match the exact 'path' attribute (note the ';' delimiter, e.g. 'platforms;android-33').","If the package was renamed/removed, find its current name in the repository XML.","Ensure all relevant REPOSITORIES entries are being fetched (some packages live in specific sub-repositories)."],"exampleFix":"# before: wrong package name format\npython3 android-sdk-manager.py add-to-lockfile lock.txt 'android-33'\n# after: use the exact path attribute\npython3 android-sdk-manager.py add-to-lockfile lock.txt 'platforms;android-33'","handlingStrategy":"validation","validationCode":"# Before calling Lockfile.add, verify the package exists\ndef package_exists(packages, name):\n    if name not in packages:\n        available = [k for k in packages if name.split(';')[0] in k]\n        print(f'Package \"{name}\" not found.')\n        if available:\n            print(f'Similar packages: {available[:5]}')\n        return False\n    return True","typeGuard":null,"tryCatchPattern":"try:\n    lockfile.add(packages, package_name)\nexcept NameError as e:\n    if 'package not found' in str(e):\n        print(f'Package \"{package_name}\" not in any repository.')\n        print('Check the exact path from the repository XML.')\n    raise","preventionTips":["Use the exact 'path' attribute from the repository XML (with ';' delimiters).","List available packages before adding to verify the name.","Remember the name format is like 'platforms;android-33', not 'android-33'."],"tags":["ci","android","sdk","package-resolution","python"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}