apache/hadoop · error · RuntimeException

Specified work directory does not exists: %s

Error message

Specified work directory does not exists: %s

What it means

MiniKdc's standalone CLI main() requires <WORKDIR> <MINIKDCPROPERTIES> <KEYTABFILE> [PRINCIPALS...]. The first argument must be an existing directory used as the KDC's working root; if File.exists() is false it throws RuntimeException 'Specified work directory does not exists: <absolute path>' before the KDC starts.

Source

Thrown at hadoop-common-project/hadoop-minikdc/src/main/java/org/apache/hadoop/minikdc/MiniKdc.java:86

 * </ul>
 * The generated krb5.conf forces TCP connections.
 */
public class MiniKdc {

  public static final String JAVA_SECURITY_KRB5_CONF =
      "java.security.krb5.conf";
  public static final String SUN_SECURITY_KRB5_DEBUG =
      "sun.security.krb5.debug";

  public static void main(String[] args) throws Exception {
    if (args.length < 4) {
      System.out.println("Arguments: <WORKDIR> <MINIKDCPROPERTIES> " +
              "<KEYTABFILE> [<PRINCIPALS>]+");
      System.exit(1);
    }
    File workDir = new File(args[0]);
    if (!workDir.exists()) {
      throw new RuntimeException("Specified work directory does not exists: "
              + workDir.getAbsolutePath());
    }
    Properties conf = createConf();
    File file = new File(args[1]);
    if (!file.exists()) {
      throw new RuntimeException("Specified configuration does not exists: "
              + file.getAbsolutePath());
    }
    Properties userConf = new Properties();
    InputStreamReader r = null;
    try {
      r = new InputStreamReader(new FileInputStream(file),
          StandardCharsets.UTF_8);
      userConf.load(r);
    } finally {
      if (r != null) {
        r.close();
      }

View on GitHub (pinned to 2add963021)

Solutions

  1. mkdir -p the workdir before launching (the parent must exist and be writable)
  2. Pass an absolute path for <WORKDIR> to avoid CI working-directory surprises
  3. Check the printed absolute path against what you intended if the launch still fails

Example fix

# before
java ... MiniKdc target/kdc conf.properties user.keytab hdfs/localhost
# after
mkdir -p /tmp/minikdc && java ... MiniKdc /tmp/minikdc /abs/conf.properties /abs/user.keytab hdfs/localhost
Defensive patterns

Strategy: validation

Validate before calling

File workDir = new File(args[0]);
if (!workDir.isDirectory() && !workDir.mkdirs())
  throw new IllegalStateException("MiniKdc workdir unusable: " + workDir.getAbsolutePath());

Prevention

When it happens

Trigger: Running `java -cp ... org.apache.hadoop.minikdc.MiniKdc /tmp/kdc ...` (or the minikdc shell/bat scripts) where the first argument names a directory that is absent, misspelled, or is a file rather than a directory.

Common situations: Integration-test harnesses that assume the build already created target/test-dir; relative paths evaluated from a different CWD in CI; typos when invoking the bundled minikdc scripts.

Related errors


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