apache/hadoop · error · IOException
Cannot copy {} to itself.
Error message
Cannot copy {} to itself. What it means
Error "Cannot copy {} to itself." thrown in apache/hadoop.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java:346
throws IOException {
fs.delete(dir, true);
}
//
// If the destination is a subdirectory of the source, then
// generate exception
//
private static void checkDependencies(FileSystem srcFS,
Path src,
FileSystem dstFS,
Path dst)
throws IOException {
if (srcFS == dstFS) {
String srcq = srcFS.makeQualified(src).toString() + Path.SEPARATOR;
String dstq = dstFS.makeQualified(dst).toString() + Path.SEPARATOR;
if (dstq.startsWith(srcq)) {
if (srcq.length() == dstq.length()) {
throw new IOException("Cannot copy " + src + " to itself.");
} else {
throw new IOException("Cannot copy " + src + " to its subdirectory " +
dst);
}
}
}
}
/**
* Copy files between FileSystems.
* @param srcFS src fs.
* @param src src.
* @param dstFS dst fs.
* @param dst dst.
* @param deleteSource delete source.
* @param conf configuration.
* @return if copy success true, not false.
* @throws IOException raised on errors performing I/O.View on GitHub (pinned to 2add963021)
Solutions
- Choose a destination different from the source path.
- Check for path canonicalization issues that make distinct paths resolve to the same file.
When it happens
Trigger: Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java:346 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/be26657e2bee4879.
Report an issue: GitHub.