{"record":{"id":"34de57a3a77f78ae","repo":"quarkusio/quarkus","slug":"failed-to-clean-up-non-modified-jars-in-lib","errorCode":null,"errorMessage":"Failed to clean up non-modified jars in lib/","messagePattern":"Failed to clean up non-modified jars in lib/","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java","lineNumber":277,"sourceCode":"            copy.include(\"lib/**\");\n        }));\n\n        // Quarkus' 'legacy-jar' package type produces 'lib/modified-*.jar' files for some dependencies.\n        // The following code block removes the non-modified jars.\n        getLogger().info(\"Cleaning up lib/ directory in {}\", buildDir);\n        try (Stream<Path> files = Files.walk(libDir)) {\n            files.filter(Files::isRegularFile).filter(f -> f.getFileName().toString().startsWith(\"modified-\"))\n                    .map(f -> f.getParent().resolve(f.getFileName().toString().substring(\"modified-\".length())))\n                    .toList() // necessary :(\n                    .forEach(f -> {\n                        try {\n                            Files.deleteIfExists(f);\n                        } catch (IOException e) {\n                            throw new RuntimeException(e);\n                        }\n                    });\n        } catch (IOException e) {\n            throw new GradleException(\"Failed to clean up non-modified jars in lib/\");\n        }\n\n        copyRunnersAndArtifactProperties(appBuildDir);\n    }\n\n    private void assembleFullBuild() {\n        File targetDir = buildDir;\n\n        // build/quarkus-build/gen\n        Path genBuildDir = genBuildDir();\n\n        if (nativeEnabled()) {\n            if (nativeSourcesOnly()) {\n                getLogger().info(\"Copying Quarkus build for native sources from {} into {}\", genBuildDir, targetDir);\n            } else {\n                getLogger().info(\"Copying Quarkus native build from {} into {}\", genBuildDir, targetDir);\n\n            }","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java#L259-L295","documentation":"During assembleLegacyJar, the Quarkus Gradle plugin deletes stale, non-modified jars from the lib/ directory of a previous legacy-jar build. If any file-system traversal or delete fails with IOException, the whole assemble step aborts with a GradleException. The original cause is not chained in this case, so the message alone must be investigated.","triggerScenarios":"IOException while walking/deleting files under the app build directory's lib/ (e.g. file locked by a running application, permission denied, directory deleted concurrently) in QuarkusBuild.assembleLegacyJar, called from finalizeQuarkusBuild.","commonSituations":"A previously started quarkusDev/quarkusRun JVM or an IDE still holds jar handles (Windows especially); build directory owned by another user after running with sudo; read-only CI workspace.","solutions":["Stop any running Quarkus dev-mode or java -jar process that locks jars in build/ (or the app build dir) and rebuild","Check permissions on the build output lib/ directory and delete it manually: rm -rf build/quarkus-app (or the configured build directory)","On Windows, close file explorers/antivirus scanning the lib dir, or restart to release locks","Run ./gradlew clean then re-run the build"],"exampleFix":"// shell-side fix\n./gradlew stop # if using quarkusDev in another terminal\nrm -rf build/quarkus-app\n./gradlew quarkusBuild","handlingStrategy":"validation","validationCode":"// before quarkusBuild, ensure nothing holds build/ open and the dir is writable\nassert new File(\"build/quarkus-app\").canWrite() || !new File(\"build/quarkus-app\").exists();","typeGuard":null,"tryCatchPattern":"try {\n    ./gradlew quarkusBuild\n} catch (GradleException e) {\n    if (e.message?.startsWith(\"Failed to clean up non-modified jars\")) {\n        \"./gradlew clean\".execute().waitFor(); retryBuild();\n    } else { throw e; }\n}","preventionTips":["Always stop quarkusDev / running app JVMs before rebuilding","Run ./gradlew clean after abnormal interruptions","On Windows, exclude build/ from antivirus/indexers","Avoid running builds with sudo into a user-owned workspace"],"tags":["gradle","file-system","legacy-jar","cleanup"],"backgroundTag":"file-lock-cleanup-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}