apache/hadoop · error · FileNotFoundException
Hadoop bin directory is not a directory.: {}
Error message
Hadoop bin directory is not a directory.: {} What it means
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'.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Shell.java:665
/**
* Inner logic of {@link #getQualifiedBin(String)}, accessible
* for tests.
* @param hadoopHomeDir home directory (assumed to be valid)
* @param executable executable
* @return path to the binary
* @throws FileNotFoundException if the executable was not found/valid
*/
static File getQualifiedBinInner(File hadoopHomeDir, String executable)
throws FileNotFoundException {
String binDirText = "Hadoop bin directory ";
File bin = new File(hadoopHomeDir, "bin");
if (!bin.exists()) {
throw new FileNotFoundException(addOsText(binDirText + E_DOES_NOT_EXIST
+ ": " + bin));
}
if (!bin.isDirectory()) {
throw new FileNotFoundException(addOsText(binDirText + E_NOT_DIRECTORY
+ ": " + bin));
}
File exeFile = new File(bin, executable);
if (!exeFile.exists()) {
throw new FileNotFoundException(
addOsText(E_NO_EXECUTABLE + ": " + exeFile));
}
if (!exeFile.isFile()) {
throw new FileNotFoundException(
addOsText(E_NOT_EXECUTABLE_FILE + ": " + exeFile));
}
try {
return exeFile.getCanonicalFile();
} catch (IOException e) {
// this isn't going to happen, because of all the upfront checks.
// so if it does, it gets converted to a FNFE and rethrown
throw fileNotFoundException(e.toString(), e);View on GitHub (pinned to 2add963021)
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
Example fix
# before $ ls -la /opt/hadoop/bin -rw-r--r-- 1 user user 4096 bin # a file, not a directory # after mv /opt/hadoop/bin /opt/hadoop/bin.broken tar -xzf hadoop-3.3.6.tar.gz -C /opt/hadoop --strip-components=1 hadoop-3.3.6/bin ls -lad /opt/hadoop/bin # drwxr-xr-x ... bin
Defensive patterns
Strategy: validation
Validate before calling
File bin = new File(new File(System.getenv("HADOOP_HOME")), "bin");
if (bin.exists() && !bin.isDirectory()) {
throw new IllegalStateException(bin + " exists but is not a directory — reinstall Hadoop bin/");
} Try / catch
try { Shell.getQualifiedBin(exe); } catch (FileNotFoundException e) { /* inspect bin entry type, repair, retry */ } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Hadoop bin directory does not exist: {}
- %s does not exist or is not file.
- Dest filesystem '${fs.getUri().getScheme()}' doesn't support
- Hadoop home directory {} does not exist
- Hadoop home directory {} is not a directory.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/086265d40889b0eb.
Report an issue: GitHub.