{"record":{"id":"b4cb58fcccabe30a","repo":"JetBrains/intellij-community","slug":"directory-0-is-already-taken-by-the-project","errorCode":null,"errorMessage":"Directory '{0}' is already taken by the project '{1}'. Please choose another location.","messagePattern":"Directory '(.+?)' is already taken by the project '(.+?)'\\. Please choose another location\\.","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"java/idea-ui/src/com/intellij/ide/util/projectWizard/NamePathComponent.java","lineNumber":175,"sourceCode":"      throw new ConfigurationException(JavaUiBundle.message(\"prompt.enter.project.file.location\", context.getPresentationName()));\n    }\n    if (myShouldBeAbsolute && !new File(projectDirectoryPath).isAbsolute()) {\n      throw new ConfigurationException(JavaUiBundle.message(\"file.location.should.be.absolute\", StringUtil.capitalize(context.getPresentationName())));\n    }\n\n    boolean shouldPromptCreation = isPathChangedByUser();\n    String message = JavaUiBundle.message(\"directory.project.file.directory\", context.getPresentationName());\n    if (!ProjectWizardUtil.createDirectoryIfNotExists(message, projectDirectoryPath, shouldPromptCreation)) {\n      return false;\n    }\n\n    File projectDirectory = new File(projectDirectoryPath);\n    if (projectDirectory.exists() && !projectDirectory.canWrite()) {\n      throw new ConfigurationException(JavaUiBundle.message(\"project.directory.is.not.writable\", projectDirectoryPath));\n    }\n    for (Project p : ProjectManager.getInstance().getOpenProjects()) {\n      if (ProjectUtil.isSameProject(projectDirectory.toPath(), p)) {\n        throw new ConfigurationException(JavaUiBundle.message(\"project.directory.is.already.taken\", projectDirectoryPath, p.getName()));\n      }\n    }\n    if (projectDirectory.exists() && !projectDirectory.isDirectory()) {\n      LOG.warn(String.format(\"Project '%s' directory should be a directory\", projectDirectoryPath));\n    }\n    boolean shouldContinue = true;\n    if (!ApplicationManager.getApplication().isUnitTestMode()) {\n      String fileName = defaultFormat ? name + ProjectFileType.DOT_DEFAULT_EXTENSION : Project.DIRECTORY_STORE_FOLDER;\n      File projectFile = new File(projectDirectory, fileName);\n      if (projectFile.exists()) {\n        message = CoreBundle.message(\"prompt.overwrite.project.file\", projectFile.getAbsolutePath(), context.getPresentationName());\n        shouldContinue = MessageDialogBuilder.yesNo(IdeBundle.message(\"title.file.already.exists\"), message).show() == Messages.YES;\n      }\n    }\n    return shouldContinue;\n  }\n\n  public String getNameValue() {","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/idea-ui/src/com/intellij/ide/util/projectWizard/NamePathComponent.java#L157-L193","documentation":"Thrown by NamePathComponent.validateNameAndPath() when the chosen directory is already the home of an open project (ProjectUtil.isSameProject matches it against every project in ProjectManager.getOpenProjects()). Two open IDE projects cannot share one directory — their .idea stores would collide — so the wizard blocks it and names the occupying project.","triggerScenarios":"Calling validateNameAndPath() with a projectDirectory path that isSameProject() considers equal to an already open project's base path (same canonical path, or the directory containing that project's .idea).","commonSituations":"Creating a 'new' project in a directory that is already open in another IDE window or the same one; symlinks/case differences resolving to the same canonical path; re-running a wizard against a checked-out project that is currently open.","solutions":["Close the existing project (the one named in the message) in its IDE window, then retry","Or point the wizard at a different, unused directory","If you only wanted to reopen it, use File > Open on the existing directory instead of New Project"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Path target = Path.of(component.getPath());\nfor (Project open : ProjectManager.getInstance().getOpenProjects()) {\n  if (ProjectUtil.isSameProject(target, open)) {\n    // tell user to close project 'open.getName()' or choose another dir\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Before New Project, check whether the target directory is already open and just File > Open it","Canonicalize paths when comparing candidate directories to avoid symlink blind spots"],"tags":["project","wizard","duplicate","directory","intellij"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}