stanfordnlp/CoreNLP · error · RuntimeException
Output path already exists
Error message
Output path ${file} already exists What it means
FileSystem.checkNotExistsOrFail(file) throws RuntimeException if the given file already exists, logging 'Output path <file> already exists'. It protects callers from overwriting prior outputs (and optional overwriting APIs from clobbering data).
Solutions
- Delete or move the existing file/directory first, or pick a fresh output path (timestamp/uuid).
- Rerun with output cleanup enabled in your pipeline.
- Point the output to a different location and use the overwrite variant if you truly intend replacement.
- Check the job that previously wrote there to avoid clobbering needed data.
Example fix
// before
FileSystem.checkNotExistsOrFail(out); // throws on rerun
// after
if (out.exists()) {
java.nio.file.Files.move(out.toPath(), out.toPath().resolveSibling(out.getName() + ".bak"));
}
FileSystem.checkNotExistsOrFail(out); Defensive patterns
Strategy: validation
Validate before calling
if (file.exists()) {
throw new IllegalStateException("Output already present, remove or rename: " + file);
} Try / catch
try {
FileSystem.checkNotExistsOrFail(out);
runJob(out);
} catch (RuntimeException e) {
log.warning("Output exists: " + e.getMessage());
} Prevention
- Clean output directories between reruns
- Generate unique output names (timestamp/uuid)
- Never point outputs at input paths
When it happens
Trigger: Calling checkNotExistsOrFail on a path that is present: rerunning a job without cleaning output, a previous crashed run left partial files, or an output path colliding with an input path.
Common situations: Batch jobs restarted without clearing the output directory; timestamps/id collisions in generated filenames; user points --output at an existing file intentionally.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- Cannot initialize logger!
- Collection elements must be Files or Strings
- Could not create
- Directory access problem for
- File doesn't exist
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/e3f95a74fc5310a8.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/io/FileSystem.java:143
String error = "Could not create " + dir;
log.info(error);
throw new RuntimeException(error);
}
}
public static void checkExistsOrFail(File file) {
if (!file.exists()) {
String error = "Output path " + file + " does not exist";
log.info(error);
throw new RuntimeException(error);
}
}
public static void checkNotExistsOrFail(File file) {
if (file.exists()) {
String error = "Output path " + file + " already exists";
log.info(error);
throw new RuntimeException(error);
}
}
/**
* Unit test code
*/
public static void main(String[] args) {
String testDirName = "FileSystemTest";
String testFileName = "Pair.java";
File testDir = new File(testDirName);
testDir.mkdir();
try {
copyFile(new File(testFileName),new File(testDirName + "/" + testFileName));
} catch (RuntimeIOException e) {
log.info("Copy failed");
System.exit(-1);View on GitHub (pinned to 1b7edd19c4)