JetBrains/intellij-community · error · IOException

error.message.unable.to.create.file

error.message.unable.to.create.file

Error message

Unable to create file ''{0}''

What it means

Thrown (as an IOException) from ConfigFileFactoryImpl.createFile when the parent directories of a descriptor config file cannot be created or the parent cannot be resolved in the VFS after refresh. It wraps FileUtil.createParentDirs failing (permissions, invalid path) or refreshAndFindFileByIoFile returning null. The IOException is caught, logged, and surfaced via a later UI callback.

Source

Thrown at java/idea-ui/src/com/intellij/util/descriptors/impl/ConfigFileFactoryImpl.java:124

    VirtualFile existingFile = fileSystem.refreshAndFindFileByIoFile(file);
    if (existingFile != null) {
      existingFile.refresh(false, false);
      if (!existingFile.isValid()) {
        existingFile = null;
      }
    }

    if (existingFile != null && !forceNew) {
      return existingFile;
    }
    try {
      String text = getText(templateName, project);
      final VirtualFile childData;
      if (existingFile == null || existingFile.isDirectory()) {
        final VirtualFile virtualFile;
        if (!FileUtil.createParentDirs(file) ||
            (virtualFile = fileSystem.refreshAndFindFileByIoFile(file.getParentFile())) == null) {
          throw new IOException(IdeBundle.message("error.message.unable.to.create.file", file.getPath()));
        }
        childData = virtualFile.createChildData(this, file.getName());
      }
      else {
        childData = existingFile;
      }
      VfsUtil.saveText(childData, text);
      return childData;
    }
    catch (final IOException e) {
      LOG.info(e);
      ApplicationManager.getApplication().invokeLater(
        () -> Messages.showErrorDialog(JavaUiBundle.message("message.text.error.creating.deployment.descriptor", e.getLocalizedMessage()),
                                     JavaUiBundle.message("message.text.creating.deployment.descriptor")));
    }
    return null;
  }

View on GitHub (pinned to be881553f2)

Solutions

  1. Check the path from the message: ensure its parent can be created (no file blocking it, no permission issue)
  2. Fix filesystem permissions or move the project/config dir to a writable location
  3. Delete a stale plain file occupying the intended parent-directory path and retry
  4. Check idea.log (LOG.info of the caught IOException) for the underlying OS error
Defensive patterns

Strategy: try-catch

Validate before calling

File parent = file.getParentFile();
if (parent != null && (parent.exists() && !parent.isDirectory())) {
  // fail early: parent path occupied by a regular file
}
if (parent != null && !parent.canWrite() && !parent.mkdirs()) {
  // fail early: cannot create parent directories
}

Try / catch

try { factory.createFile(...); } catch (IOException e) { LOG.info(e); /* surface 'Unable to create file <path>' with retry/choose-another-path actions */ }

Prevention

When it happens

Trigger: Calling ConfigFileFactory.createFile with a File whose parent directory is not creatable — read-only parent, a parent path that is actually a file, or a path the VFS cannot find after refresh. Happens when a plugin/module descriptor config file is first generated.

Common situations: Project located on a read-only or network mount; leftover file where a directory is expected; path length or character restrictions on Windows; antivirus locking directories during creation.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/0c85cd68347b37b0. Report an issue: GitHub.