{"record":{"id":"35e6ded9de6fd7bb","repo":"gradle/gradle","slug":"project-accessors-enabled-but-root-project-name-n","errorCode":null,"errorMessage":"Project accessors enabled, but root project name not explicitly set for '{}'. Checking out the project in different folders will impact the generated code and implicitly the buildscript classpath, breaking caching.","messagePattern":"Project accessors enabled, but root project name not explicitly set for '(.+?)'\\. Checking out the project in different folders will impact the generated code and implicitly the buildscript classpath, breaking caching\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"platforms/software/dependency-management/src/main/java/org/gradle/api/internal/catalog/DefaultDependenciesAccessors.java","lineNumber":185,"sourceCode":"            throw new RuntimeException(e);\n        }\n    }\n\n    private void writeDependenciesAccessors(DefaultVersionCatalog model) {\n        executeWork(new DependencyAccessorUnitOfWork(model));\n    }\n\n    private void writeProjectAccessors(ProjectDescriptorRegistry projectRegistry) {\n        if (!assertCanGenerateAccessors(projectRegistry)) {\n            return;\n        }\n        warnIfRootProjectNameNotSetExplicitly(projectRegistry.getRootProject());\n        executeWork(new ProjectAccessorUnitOfWork(projectRegistry));\n    }\n\n    private static void warnIfRootProjectNameNotSetExplicitly(@Nullable ProjectDescriptorInternal project) {\n        if (!project.isExplicitName()) {\n            LOGGER.warn(\"Project accessors enabled, but root project name not explicitly set for '\" + project.getName() +\n                \"'. Checking out the project in different folders will impact the generated code and implicitly the buildscript classpath, breaking caching.\");\n        }\n    }\n\n    private void executeWork(UnitOfWork work) {\n        ExecutionEngine.Result result = engine.createRequest(work).execute();\n        GeneratedAccessors accessors = result.getOutputAs(GeneratedAccessors.class).get();\n        ClassPath generatedClasses = DefaultClassPath.of(accessors.classesDir);\n        sources = sources.plus(DefaultClassPath.of(accessors.sourcesDir));\n        classes = classes.plus(generatedClasses);\n        classLoaderScope.export(generatedClasses);\n    }\n\n    private static boolean assertCanGenerateAccessors(ProjectDescriptorRegistry projectRegistry) {\n        List<String> errors = new ArrayList<>();\n        projectRegistry.getAllProjects()\n            .stream()\n            .map(ProjectDescriptor::getName)","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/software/dependency-management/src/main/java/org/gradle/api/internal/catalog/DefaultDependenciesAccessors.java#L167-L203","documentation":"Emitted from DefaultDependenciesAccessors.writeProjectAccessors -> warnIfRootProjectNameNotSetExplicitly when type-safe accessors are generated but the root project's name is only the default (directory-derived) one (ProjectDescriptorInternal.isExplicitName() == false). The generated accessor code embeds the root project name, so the buildscript classpath hash changes when the same build is checked out under a different folder name, breaking build caching and configuration cache reuse across checkouts.","triggerScenarios":"A settings.gradle(.kts) that never sets rootProject.name = '...' while project accessors are generated (any build referencing projects.<name> or using version catalogs/accessors where generation is enabled). assertCanGenerateAccessors must pass first, then the isExplicitName check fails.","commonSituations":"CI checkouts into varying directories (Jenkins workspace-123, pipeline hashes); generated/Multi-repo setups; builds migrated from Ant/Maven where the folder was always the project name; accessing projects.foo in build scripts for the first time.","solutions":["Set the root project name explicitly in settings.gradle(.kts): rootProject.name = 'my-project'.","Pick a name that does not depend on the checkout directory and commit it with the settings file.","Verify the warning disappears on the next configuration and that build cache keys are now stable across checkouts."],"exampleFix":"// before: settings.gradle.kts contains no root project name\n// after:\nrootProject.name = \"my-app\"","handlingStrategy":"validation","validationCode":"# fail fast in CI if the root project name is not pinned\ngrep -n 'rootProject.name' settings.gradle settings.gradle.kts 2>/dev/null \\\n  || { echo 'MISSING rootProject.name — accessor generation will break caching'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set rootProject.name when creating a new build; treat it as required boilerplate like the settings file itself.","Never rely on the checkout directory name as project identity in CI pipelines or generated workspaces.","Add the grep check above to CI so renames or new modules cannot silently drop the setting."],"tags":["settings","project-accessors","caching","root-project-name","buildscript-classpath"],"backgroundTag":"root-project-name-not-set","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}