{"record":{"id":"fe1ed78d6aee49db","repo":"JetBrains/intellij-community","slug":"module-paths-validation-duplicate-content-error","errorCode":"module.paths.validation.duplicate.content.error","errorMessage":"Content root ''{0}'' is defined for modules ''{1}'' and ''{2}''.\nTwo modules in a project cannot share the same content root.","messagePattern":"Content root ''(.+?)'' is defined for modules ''(.+?)'' and ''(.+?)''\\.\nTwo modules in a project cannot share the same content root\\.","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModulesConfigurator.java","lineNumber":307,"sourceCode":"        if (!sourceRoots.add(root)) {\n          throw new ConfigurationException(\n            JavaUiBundle.message(\"module.paths.validation.duplicate.source.root.in.same.module.error\", root.getPresentableUrl(),\n                                 moduleName));\n        }\n      }\n    }\n\n    // Check for duplicate content roots across modules and map source roots to content roots\n    for (ContentEntry contentEntry : contents) {\n      final VirtualFile contentRoot = contentEntry.getFile();\n      if (contentRoot == null) {\n        continue;\n      }\n\n      // Check for duplicate content roots\n      final String previousName = contentRootToModuleNameMap.put(contentRoot, moduleName);\n      if (previousName != null && !previousName.equals(moduleName)) {\n        throw new ConfigurationException(\n          JavaUiBundle.message(\"module.paths.validation.duplicate.content.error\", contentRoot.getPresentableUrl(), previousName, moduleName)\n        );\n      }\n\n      // Map source roots to content roots and check for duplicates\n      for (VirtualFile srcRoot : contentEntry.getSourceFolderFiles()) {\n        final VirtualFile anotherContentRoot = srcRootsToContentRootMap.put(srcRoot, contentRoot);\n        if (anotherContentRoot != null) {\n          throwDuplicateSourceRootError(srcRoot, contentRoot, anotherContentRoot, contentRootToModuleNameMap);\n        }\n      }\n    }\n  }\n\n  /**\n   * Throws an appropriate error for duplicate source roots.\n   */\n  private static void throwDuplicateSourceRootError(@NotNull VirtualFile srcRoot,","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModulesConfigurator.java#L289-L325","documentation":"Thrown by ModulesConfigurator when the exact same content root directory is assigned to two different modules (contentRootToModuleNameMap.put returns the previous, different module name). Two modules cannot share a content root — both would claim the same files for indexing, VCS and compilation — so the model update is rejected.","triggerScenarios":"Applying Project Structure changes where module A and module B each list the same directory as a content root; happens when the configurator validates editors in order and the second module's put() collides with the first's map entry.","commonSituations":"Importing two Maven/Gradle projects that both claim a shared parent directory; hand-edited .iml files copy-pasting a content url; splitting a module but forgetting to remove the old content entry; duplicate module import (same sources imported twice).","solutions":["In Project Structure > Modules, remove the content root from one of the two modules named in the message","If the module is a duplicate import, delete the redundant module entirely","Fix the .iml files: ensure each <content url=\"...\"> appears in exactly one module","For multi-project setups sharing sources, use one module with multiple source roots instead of two modules sharing one root"],"exampleFix":"<!-- before: two modules both declare content root $PROJECT_DIR$/shared -->\n<!-- module-a.iml -->\n<content url=\"file://$PROJECT_DIR$/shared\"/>\n<!-- module-b.iml -->\n<content url=\"file://$PROJECT_DIR$/shared\"/>\n\n<!-- after: only module-a owns it -->\n<!-- module-a.iml -->\n<content url=\"file://$PROJECT_DIR$/shared\"/>\n<!-- module-b.iml -->\n<content url=\"file://$PROJECT_DIR$/b-own-root\"/>","handlingStrategy":"validation","validationCode":"Map<VirtualFile, String> owner = new HashMap<>();\nfor (Module m : ModuleManager.getInstance(project).getModules()) {\n  for (ContentEntry c : ModuleRootManager.getInstance(m).getContentEntries()) {\n    VirtualFile root = c.getFile();\n    if (root != null && owner.put(root, m.getName()) != null) {\n      // two modules share this content root: remove it from one before apply\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  configurator.apply();\n} catch (ConfigurationException e) {\n  // message names both modules; drop the content root from the redundant one and retry\n}","preventionTips":["Never copy a <content url=\"...\"> block from one .iml to another","Import shared sources once; use a single module with multiple source roots instead","Run a periodic check that content root urls are unique across modules"],"tags":["module","content-root","duplicate","project-structure","iml","intellij"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}