{"record":{"id":"e23f4b04412606a1","repo":"apache/cassandra","slug":"history-file-s-does-not-exist-n","errorCode":null,"errorMessage":"History file %s does not exist.%n","messagePattern":"History file (.+?) does not exist\\.%n","errorType":"console","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/History.java","lineNumber":88,"sourceCode":"        if (commands > size)\n            commandLines = historyCommands;\n        else\n            commandLines = historyCommands.subList(size - commands, size);\n\n        return commandLines;\n    }\n\n    /**\n     * Nodetool is appending command to history file before it is executed so us checking on its\n     * existence and validating it is not technically necessary however nodetool is also swallowing\n     * all errors when it was not succesful in appending to the history file so better to check here in that case.\n     *\n     * @param historyFile file to check that it is actually a file which exists and it is readable\n     */\n    void validateHistoryFile(File historyFile)\n    {\n        if (!historyFile.exists())\n            throw new IllegalStateException(String.format(\"History file %s does not exist.%n\", historyFile.absolutePath()));\n\n        if (!historyFile.isFile())\n            throw new IllegalStateException(String.format(\"History file %s is not a file.%n\", historyFile.absolutePath()));\n\n        if (!historyFile.isReadable())\n            throw new IllegalStateException(String.format(\"History file %s is not readable.%n\", historyFile.absolutePath()));\n    }\n}\n","sourceCodeStart":70,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/History.java#L70-L97","documentation":"History.validateHistoryFile checks that the nodetool history file (usually ~/.cassandra/nodetool.history) exists before reading it. If it does not exist, it throws IllegalStateException formatted with the absolute path. The trailing %n produces a newline inside the message.","triggerScenarios":"Running `nodetool history` when no history file has ever been written (history logging disabled, HOME not set correctly, or the file was deleted).","commonSituations":"Fresh user accounts or CI containers where nodetool has never been run interactively; HOME pointing elsewhere so nodetool looks in the wrong directory; history disabled via nodetool.settings.","solutions":["Run any nodetool command once with history enabled so the file is created, then retry","Check that $HOME is set correctly and ~/.cassandra is writable","Verify the expected path printed in the message and point to the right user account","If history is intentionally disabled, don't use the history subcommand"],"exampleFix":"// before\nexport HOME=/nonexistent && nodetool history\n// after\nexport HOME=/home/cassandra && nodetool history","handlingStrategy":"fallback","validationCode":"# ensure history file exists before running nodetool history\nHIST=\"$HOME/.cassandra/nodetool.history\"\n[ -f \"$HIST\" ] || { echo \"history file missing at $HIST\"; exit 1; }","typeGuard":null,"tryCatchPattern":"try { runNodetool(\"history\"); } catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"does not exist\")) { log(\"No nodetool history recorded yet\"); return; }\n    throw e;\n}","preventionTips":["Ensure $HOME is set for the user running nodetool","Run at least one nodetool command before expecting history","Don't delete ~/.cassandra/nodetool.history in cleanup scripts if you rely on `nodetool history`"],"tags":["nodetool","history","filesystem","cli"],"backgroundTag":"file-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}