{"record":{"id":"a6498096269f9746","repo":"JetBrains/intellij-community","slug":"module-0-already-exist-in-project-please-spe","errorCode":null,"errorMessage":"Module '{0}' already exist in project. Please, specify another name.","messagePattern":"Module '(.+?)' already exist in project\\. Please, specify another name\\.","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"java/idea-ui/src/com/intellij/ide/projectWizard/ModuleNameLocationComponent.java","lineNumber":346,"sourceCode":"\n  private void validateExistingModuleName() throws ConfigurationException {\n    Project project = myWizardContext.getProject();\n    if (project == null) return;\n\n    final String moduleName = getModuleName();\n    final Module module;\n    final ProjectStructureConfigurable fromConfigurable = ProjectStructureConfigurable.getInstance(project);\n    ModifiableModuleModel modifiableModel =\n      fromConfigurable != null ? fromConfigurable.getContext().getModulesConfigurator().getModuleModel()\n                               : null;\n    if (modifiableModel != null) {\n      module = modifiableModel.findModuleByName(moduleName);\n    }\n    else {\n      module = ModuleManager.getInstance(project).findModuleByName(moduleName);\n    }\n    if (module != null) {\n      throw new ConfigurationException(\n        JavaUiBundle.message(\"module.name.location.dialog.message.module.already.exist.in.project\", moduleName));\n    }\n  }\n\n  private boolean validateModulePaths() throws ConfigurationException {\n    String moduleName = getModuleName();\n    String moduleFileDirectory = myModuleFileLocation.getText();\n    if (moduleFileDirectory.isEmpty()) {\n      throw new ConfigurationException(JavaUiBundle.message(\"module.name.location.dialog.message.enter.module.file.location\"));\n    }\n    if (moduleName.isEmpty()) {\n      throw new ConfigurationException(JavaUiBundle.message(\"module.name.location.dialog.message.enter.module.name\"));\n    }\n\n    if (!ProjectWizardUtil.createDirectoryIfNotExists(JavaUiBundle.message(\"directory.module.file\"), moduleFileDirectory,\n                                                      myImlLocationChangedByUser)) {\n      return false;\n    }","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/idea-ui/src/com/intellij/ide/projectWizard/ModuleNameLocationComponent.java#L328-L364","documentation":"Thrown by ModuleNameLocationComponent during new-module wizard validation when a module with the typed name already exists in the project. Module names must be unique per project, so the wizard blocks creation and asks for a different name.","triggerScenarios":"Calling validate() on the module name/location step (or ModuleManager.findModuleByName / modifiableModel.findModuleByName returning non-null) with a name that duplicates an existing module; happens in both wizard mode and the Project Structure dialog when a ModifiableModuleModel is active.","commonSituations":"Importing a second copy of the same project/sources into one window (two modules named 'core'); Maven/Gradle subproject name collision after renaming; user types a name identical to an existing module; wizard pre-fills a default name that already exists.","solutions":["Type a different, unique module name in the wizard's name field","If the existing module is a leftover, delete or rename it first (File > Project Structure > Modules)","When importing duplicated sources, give each import a distinct name prefix (e.g. 'copy-core')","In plugin code, pre-check ModuleManager.getInstance(project).findModuleByName(name) == null before showing the step"],"exampleFix":"// before\nString moduleName = \"core\"; // project already has a module 'core'\nwizard.validate(); // ConfigurationException: module already exist\n\n// after\nString moduleName = \"core2\";\nassert ModuleManager.getInstance(project).findModuleByName(moduleName) == null;\nwizard.validate();","handlingStrategy":"validation","validationCode":"String candidate = nameField.getText().trim();\nModule existing = ModuleManager.getInstance(project).findModuleByName(candidate);\nif (existing != null) {\n  // pick another name / disable Finish before the wizard validates\n}","typeGuard":null,"tryCatchPattern":"try {\n  component.validate();\n} catch (ConfigurationException e) {\n  // if duplicate-module message, auto-suffix: name + \"2\" and revalidate once\n}","preventionTips":["Derive default module names that cannot collide (append counter until unique)","Never import the same sources twice into one project window; use a separate window","Rename stale modules before creating new ones with the same name"],"tags":["module","wizard","duplicate","project-structure","intellij"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}