{"record":{"id":"dc36556429d4afb8","repo":"apache/hadoop","slug":"destination-dest-should-be-a-directory-but-is-a","errorCode":null,"errorMessage":"Destination {dest} should be a directory but is a file","messagePattern":"Destination (.+?) should be a directory but is a file","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-archives/src/main/java/org/apache/hadoop/tools/HadoopArchives.java","lineNumber":487,"sourceCode":"    int numFiles = 0;\n    long totalSize = 0;\n    FileSystem fs = parentPath.getFileSystem(conf);\n    this.blockSize = conf.getLong(HAR_BLOCKSIZE_LABEL, blockSize);\n    this.partSize = conf.getLong(HAR_PARTSIZE_LABEL, partSize);\n    conf.setLong(HAR_BLOCKSIZE_LABEL, blockSize);\n    conf.setLong(HAR_PARTSIZE_LABEL, partSize);\n    conf.set(DST_HAR_LABEL, archiveName);\n    conf.set(SRC_PARENT_LABEL, fs.makeQualified(parentPath).toString());\n    conf.setInt(HAR_REPLICATION_LABEL, repl);\n    Path outputPath = new Path(dest, archiveName);\n    FileOutputFormat.setOutputPath(conf, outputPath);\n    FileSystem outFs = outputPath.getFileSystem(conf);\n    if (outFs.exists(outputPath)) {\n      throw new IOException(\"Archive path: \"\n          + outputPath.toString() + \" already exists\");\n    }\n    if (outFs.isFile(dest)) {\n      throw new IOException(\"Destination \" + dest.toString()\n          + \" should be a directory but is a file\");\n    }\n    conf.set(DST_DIR_LABEL, outputPath.toString());\n    Credentials credentials = conf.getCredentials();\n    Path[] allPaths = new Path[] {parentPath, dest};\n    TokenCache.obtainTokensForNamenodes(credentials, allPaths, conf);\n    conf.setCredentials(credentials);\n\n    Path stagingArea;\n    try {\n      stagingArea = JobSubmissionFiles.getStagingDir(new Cluster(conf), \n          conf);\n    } catch (InterruptedException ie) {\n      throw new IOException(ie);\n    }\n    Path jobDirectory = new Path(stagingArea,\n        NAME+\"_\"+Integer.toString(new Random().nextInt(Integer.MAX_VALUE), 36));\n    FsPermission mapredSysPerms = ","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-archives/src/main/java/org/apache/hadoop/tools/HadoopArchives.java#L469-L505","documentation":"Error \"Destination {dest} should be a directory but is a file\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-tools/hadoop-archives/src/main/java/org/apache/hadoop/tools/HadoopArchives.java:487 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a destination path that is a directory or does not exist; the destination currently exists as a file."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}