{"record":{"id":"63e68b030847cc39","repo":"quarkusio/quarkus","slug":"failed-to-resolve-coords-locally","errorCode":null,"errorMessage":"Failed to resolve ${coords} locally","messagePattern":"Failed to resolve (.+?) locally","errorType":"exception","errorClass":"RegistryResolutionException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/client/maven/MavenRegistryCache.java","lineNumber":53,"sourceCode":"        }\n        if (config.getPlatforms() != null) {\n            artifacts.add(config.getPlatforms().getArtifact());\n        }\n        this.artifacts = artifacts;\n        this.resolver = Objects.requireNonNull(resolver);\n        this.log = Objects.requireNonNull(log);\n    }\n\n    @Override\n    public void clearCache() throws RegistryResolutionException {\n        log.debug(\"%s clearCache\", config.getId());\n        for (ArtifactCoords coords : artifacts) {\n            final Path dir;\n            try {\n                dir = resolver.findArtifactDirectory(new DefaultArtifact(coords.getGroupId(), coords.getArtifactId(),\n                        coords.getClassifier(), coords.getType(), coords.getVersion()));\n            } catch (BootstrapMavenException e) {\n                throw new RegistryResolutionException(\"Failed to resolve \" + coords + \" locally\", e);\n            }\n            if (Files.exists(dir)) {\n                try (Stream<Path> dirPaths = Files.list(dir)) {\n                    dirPaths.forEach(path -> {\n                        try {\n                            Files.delete(path);\n                        } catch (IOException e) {\n                        }\n                    });\n                } catch (IOException e) {\n                    throw new RegistryResolutionException(\"Failed to read directory \" + dir, e);\n                }\n            }\n        }\n    }\n}\n","sourceCodeStart":35,"sourceCodeEnd":70,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/registry-client/src/main/java/io/quarkus/registry/client/maven/MavenRegistryCache.java#L35-L70","documentation":"Thrown by MavenRegistryCache.clearCache when it tries to locate the local Maven repository directory of an artifact to evict it from the cache. resolver.findArtifactDirectory wrapped a BootstrapMavenException, meaning the artifact could not be located/resolved locally, so the cache-clearing operation aborts with this RegistryResolutionException naming the artifact coords.","triggerScenarios":"Calling MavenRegistryCache.clearCache with a list of ArtifactCoords where at least one artifact is not present in (or not resolvable from) the local Maven repository — findArtifactDirectory throws BootstrapMavenException before any deletion can happen.","commonSituations":"Clearing the registry cache after the artifacts were already deleted by a previous clearCache run or manual cleanup; typos or stale coordinates in the artifact list (e.g. a version that was never downloaded); running against a different/empty -Dmaven.repo.local directory than the one used previously.","solutions":["Verify the artifact actually exists in the local repository (ls ~/.m2/repository/<group-path>/<artifact>/<version>); if it is already gone, no clearing is needed.","Correct the ArtifactCoords passed to clearCache — check groupId/artifactId/version spelling and that the version was ever downloaded.","Point the resolver at the same local repository (maven.repo.local) used when the artifacts were first downloaded.","Re-download the artifact first (mvn dependency:get) if you intend to purge and refresh it.","Consider treating missing artifacts as a no-op by checking existence before calling clearCache."],"exampleFix":"// before: clearing unconditionally, aborts when artifact is absent\ncache.clearCache(List.of(ArtifactCoords.jar(\"io.quarkus\", \"quarkus-core\", \"3.2.5.Final\")));\n// after: only clear artifacts that resolve locally\nif (resolver.hasArtifact(coords)) { // or wrap per-artifact\n    cache.clearCache(List.of(coords));\n}","handlingStrategy":"validation","validationCode":"// verify the artifact exists in the local repo before calling clearCache\nPath expectedDir = Path.of(\n    System.getProperty(\"maven.repo.local\", System.getProperty(\"user.home\") + \"/.m2/repository\"),\n    coords.getGroupId().replace('.', '/'),\n    coords.getArtifactId(), coords.getVersion());\nif (!Files.isDirectory(expectedDir)) {\n    // nothing to clear — skip instead of triggering the error\n    return;\n}","typeGuard":"static boolean artifactCachedLocally(ArtifactCoords coords) {\n    Path dir = Path.of(System.getProperty(\"maven.repo.local\",\n            System.getProperty(\"user.home\") + \"/.m2/repository\"))\n        .resolve(coords.getGroupId().replace('.', '/'))\n        .resolve(coords.getArtifactId())\n        .resolve(coords.getVersion());\n    return Files.isDirectory(dir);\n}","tryCatchPattern":"try {\n    cache.clearCache(artifacts);\n} catch (RegistryResolutionException e) {\n    if (e.getMessage().startsWith(\"Failed to resolve\") && e.getMessage().contains(\"locally\")) {\n        log.warn(\"Artifact not in local repo, skipping: \" + e.getMessage()); // already gone — treat as cleared\n    } else throw e;\n}","preventionTips":["Filter the artifact list to coordinates known to exist before clearing.","Use the same maven.repo.local setting across runs so artifacts resolve consistently.","Double-check coordinate spelling/version before passing to clearCache.","Treat 'not found locally' as already-cleared in idempotent cache-management code.","Call clearCache with per-artifact granularity so one missing artifact does not abort the rest."],"tags":["maven","cache","local-repository","artifact-resolution"],"backgroundTag":"artifact-resolution-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}