{"record":{"id":"086265d40889b0eb","repo":"apache/hadoop","slug":"hadoop-bin-directory-is-not-a-directory","errorCode":null,"errorMessage":"Hadoop bin directory is not a directory.: {}","messagePattern":"Hadoop bin directory is not a directory\\.: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java","lineNumber":665,"sourceCode":"\n  /**\n   * Inner logic of {@link #getQualifiedBin(String)}, accessible\n   * for tests.\n   * @param hadoopHomeDir home directory (assumed to be valid)\n   * @param executable executable\n   * @return path to the binary\n   * @throws FileNotFoundException if the executable was not found/valid\n   */\n  static File getQualifiedBinInner(File hadoopHomeDir, String executable)\n      throws FileNotFoundException {\n    String binDirText = \"Hadoop bin directory \";\n    File bin = new File(hadoopHomeDir, \"bin\");\n    if (!bin.exists()) {\n      throw new FileNotFoundException(addOsText(binDirText + E_DOES_NOT_EXIST\n          + \": \" + bin));\n    }\n    if (!bin.isDirectory()) {\n      throw new FileNotFoundException(addOsText(binDirText + E_NOT_DIRECTORY\n          + \": \" + bin));\n    }\n\n    File exeFile = new File(bin, executable);\n    if (!exeFile.exists()) {\n      throw new FileNotFoundException(\n          addOsText(E_NO_EXECUTABLE + \": \" + exeFile));\n    }\n    if (!exeFile.isFile()) {\n      throw new FileNotFoundException(\n          addOsText(E_NOT_EXECUTABLE_FILE + \": \" + exeFile));\n    }\n    try {\n      return exeFile.getCanonicalFile();\n    } catch (IOException e) {\n      // this isn't going to happen, because of all the upfront checks.\n      // so if it does, it gets converted to a FNFE and rethrown\n      throw fileNotFoundException(e.toString(), e);","sourceCodeStart":647,"sourceCodeEnd":683,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java#L647-L683","documentation":"Shell.getQualifiedBinInner() found an entry named bin under the validated Hadoop home, but it is not a directory (java.io.File.isDirectory() is false), so executables cannot live inside it and FileNotFoundException is thrown. Typically a regular file, a broken symlink, or a mount oddity occupies the name 'bin'.","triggerScenarios":"A file named bin (e.g. a script or archive accidentally named 'bin') exists directly under HADOOP_HOME when Shell.getQualifiedBin() resolves an executable; likewise a dangling symlink at ${HADOOP_HOME}/bin.","commonSituations":"Someone created a helper script literally called bin; a truncated copy left a file mid-transfer; symlinks broken by moving the install; Windows junctions pointing at deleted targets.","solutions":["Inspect it: ls -la \"$HADOOP_HOME/bin\" to see whether it is a file, symlink, or directory","If a file, remove/rename it and restore the real bin/ directory from the distribution","Repoint broken symlinks at the actual bin directory of the extracted distribution","Re-extract the Hadoop (or winutils) archive to rebuild a correct directory tree"],"exampleFix":"# before\n$ ls -la /opt/hadoop/bin\n-rw-r--r-- 1 user user 4096 bin   # a file, not a directory\n\n# after\nmv /opt/hadoop/bin /opt/hadoop/bin.broken\ntar -xzf hadoop-3.3.6.tar.gz -C /opt/hadoop --strip-components=1 hadoop-3.3.6/bin\nls -lad /opt/hadoop/bin   # drwxr-xr-x ... bin","handlingStrategy":"validation","validationCode":"File bin = new File(new File(System.getenv(\"HADOOP_HOME\")), \"bin\");\nif (bin.exists() && !bin.isDirectory()) {\n  throw new IllegalStateException(bin + \" exists but is not a directory — reinstall Hadoop bin/\");\n}","typeGuard":null,"tryCatchPattern":"try { Shell.getQualifiedBin(exe); } catch (FileNotFoundException e) { /* inspect bin entry type, repair, retry */ }","preventionTips":["After extracting/copying Hadoop, assert test -d \"$HADOOP_HOME/bin\"","Avoid hand-creating files or symlinks named 'bin' in the Hadoop home","Treat a non-directory 'bin' as a corrupted install: rebuild from the original archive"],"tags":["hadoop","shell","bin-directory","filesystem","filenotfound"],"backgroundTag":"invalid-hadoop-home","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}