apache/hadoop · error · UnsupportedOperationException

SetWorkingDirectory is not supported in pseudo local file sy

Error message

SetWorkingDirectory is not supported in pseudo local file system.

What it means

PseudoLocalFs.setWorkingDirectory() unconditionally throws UnsupportedOperationException. The file system has a single fixed home/working directory ('/' by default, or the Path passed to the constructor) and no directory hierarchy, so changing the working directory cannot be meaningful. getWorkingDirectory() and getHomeDirectory() always return that fixed root.

Source

Thrown at hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/PseudoLocalFs.java:329

    throw new UnsupportedOperationException("Mkdirs is not supported"
        + " in pseudo local file system.");
  }

  @Override
  public boolean rename(Path src, Path dst) throws IOException {
    throw new UnsupportedOperationException("Rename is not supported"
        + " in pseudo local file system.");
  }

  @Override
  public boolean delete(Path path, boolean recursive) {
    throw new UnsupportedOperationException("File deletion is not supported "
        + "in pseudo local file system.");
  }

  @Override
  public void setWorkingDirectory(Path newDir) {
    throw new UnsupportedOperationException("SetWorkingDirectory "
        + "is not supported in pseudo local file system.");
  }

  @Override
  public Path makeQualified(Path path) {
    // skip FileSystem#checkPath() to validate some other Filesystems
    return path.makeQualified(this.getUri(), this.getWorkingDirectory());
  }
}

View on GitHub (pinned to 2add963021)

Solutions

  1. Do not make PseudoLocalFs the default FileSystem; reference pseudo-local files by fully-qualified pseudo:/// URIs while the default FS remains a real one
  2. Skip setWorkingDirectory when fs.getUri().getScheme().equals("pseudo")
  3. If a custom home is needed, construct PseudoLocalFs with the desired home Path (constructor argument) instead of mutating it later
Defensive patterns

Strategy: try-catch

Validate before calling

if (!"pseudo".equals(fs.getUri().getScheme())) {
  fs.setWorkingDirectory(dir);
}

Try / catch

try {
  fs.setWorkingDirectory(newDir);
} catch (UnsupportedOperationException e) {
  // pseudo FS has a fixed working dir; proceed with fully-qualified paths
}

Prevention

When it happens

Trigger: Calling FileSystem.setWorkingDirectory(Path) on a PseudoLocalFs instance; frameworks that set the working directory per task or per operation (many InputFormats and commit protocols do this) when the default FileSystem is pseudo:///

Common situations: Setting fs.defaultFS or a job's working directory to pseudo:/// so that PseudoLocalFs becomes the default FileSystem, which makes generic Hadoop code call setWorkingDirectory on it; harnesses that call setWorkingDirectory defensively at task start.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/20b5d9d7a16d0634. Report an issue: GitHub.