apache/hadoop · error · IOException
Har: mkdirs not allowed
Error message
Har: mkdirs not allowed
What it means
mkdirs throws 'Har: mkdirs not allowed' because a har has no writable namespace: directories exist only as index entries created by the archive tool. Any attempt to create directories inside har:// fails unconditionally.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java:824
/**
* return the top level archive path.
*/
@Override
public Path getHomeDirectory() {
return new Path(uri.toString());
}
@Override
public void setWorkingDirectory(Path newDir) {
//does nothing.
}
/**
* not implemented.
*/
@Override
public boolean mkdirs(Path f, FsPermission permission) throws IOException {
throw new IOException("Har: mkdirs not allowed");
}
/**
* not implemented.
*/
@Override
public void copyFromLocalFile(boolean delSrc, boolean overwrite,
Path src, Path dst) throws IOException {
throw new IOException("Har: copyfromlocalfile not allowed");
}
@Override
public void copyFromLocalFile(boolean delSrc, boolean overwrite,
Path[] srcs, Path dst) throws IOException {
throw new IOException("Har: copyfromlocalfile not allowed");
}
/**View on GitHub (pinned to 2add963021)
Solutions
- Create directories on the underlying HDFS before running `hadoop archive`, not after
- Point output-directory configuration at a writable filesystem (hdfs://)
- Make 'ensure directory exists' helpers tolerate read-only filesystems instead of calling mkdirs blindly
Example fix
// before
if (!fs.exists(outDir)) { fs.mkdirs(outDir); } // outDir is har://
// after
if ("har".equals(outDir.toUri().getScheme())) {
throw new IllegalArgumentException("cannot create directories under read-only " + outDir);
}
if (!fs.exists(outDir)) { fs.mkdirs(outDir); } Defensive patterns
Strategy: validation
Validate before calling
if ("har".equals(outDir.toUri().getScheme())) {
throw new UnsupportedOperationException("cannot mkdirs under read-only har: " + outDir);
}
if (!fs.exists(outDir)) { fs.mkdirs(outDir); } Prevention
- Validate output-directory schemes in job setup before any mkdirs call
- Make 'ensure dir exists' helpers read-only-aware instead of calling mkdirs unconditionally
When it happens
Trigger: fs.mkdirs(harPath) — typically job setup that pre-creates output directories, or copy utilities that ensure the destination directory exists before writing.
Common situations: Frameworks whose setup step is `if (!fs.exists(outDir)) fs.mkdirs(outDir)` receiving a har:// output path; deployment scripts preparing directory trees across mixed filesystems.
Related errors
- Har: create not allowed.
- Har: append not allowed.
- Har: setReplication not allowed
- Har: rename not allowed
- Har: truncate not allowed
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/d7f1ddfc86ecdfc6.
Report an issue: GitHub.