{"record":{"id":"e826b24a706e6a74","repo":"apache/cassandra","slug":"s-exists-but-is-not-writable-e826b2","errorCode":null,"errorMessage":"%s exists but is not writable","messagePattern":"(.+?) exists but is not writable","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/io/sstable/StressCQLSSTableWriter.java","lineNumber":409,"sourceCode":"            return inDirectory(new File(directory));\n        }\n\n        /**\n         * The directory where to write the sstables (mandatory option).\n         * <p>\n         * This is a mandatory option.\n         *\n         * @param directory the directory to use, which should exist and be writable.\n         * @return this builder.\n         *\n         * @throws IllegalArgumentException if {@code directory} doesn't exist or is not writable.\n         */\n        public Builder inDirectory(File directory)\n        {\n            if (!directory.exists())\n                throw new IllegalArgumentException(directory + \" doesn't exists\");\n            if (!directory.canWrite())\n                throw new IllegalArgumentException(directory + \" exists but is not writable\");\n\n            directoryList.add(directory);\n            return this;\n        }\n\n        /**\n         * A pre-instanciated ColumnFamilyStore\n         * <p>\n         * This is can be used in place of inDirectory and forTable\n         *\n         * @see #inDirectory(File)\n         *\n         * @param cfs the list of directories to use, which should exist and be writable.\n         * @return this builder.\n         *\n         * @throws IllegalArgumentException if a directory doesn't exist or is not writable.\n         */\n        public Builder withCfs(ColumnFamilyStore cfs)","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/io/sstable/StressCQLSSTableWriter.java#L391-L427","documentation":"StressCQLSSTableWriter.Builder.inDirectory(File) also requires the directory to be writable, since SSTables must be written into it. It throws IllegalArgumentException when the File exists but the process lacks write permission on it.","triggerScenarios":"Calling inDirectory(File) with an existing directory that the current OS user cannot write to (e.g. root-owned directory, read-only mount, restrictive umask).","commonSituations":"Running the stress tool as a non-root user while the output dir is root-owned; read-only container filesystem or volume; NFS mount exported read-only.","solutions":["chmod/chown the directory so the running user can write to it.","Choose a different output directory the user can write to (e.g. under the user's home).","Test with dir.canWrite() before calling inDirectory.","Check whether the mount is read-only and remount read-write."],"exampleFix":"// before\nbuilder.inDirectory(new File(\"/var/lib/cassandra/data\")); // owned by cassandra user\n// after\nbuilder.inDirectory(new File(System.getProperty(\"java.io.tmpdir\"), \"sstable-out\"));","handlingStrategy":"validation","validationCode":"File dir = new File(path);\nif (!dir.canWrite()) throw new IllegalStateException(\"not writable: \" + dir);\nbuilder.inDirectory(dir);","typeGuard":null,"tryCatchPattern":"try { builder.inDirectory(dir); }\ncatch (IllegalArgumentException e) { throw new IllegalStateException(\"fix permissions on \" + dir, e); }","preventionTips":["Check canWrite() before passing directories.","Run the tool as a user with write access to the output path.","Avoid read-only mounts for output directories.","chmod/chown output directories in deployment scripts."],"tags":["filesystem","permissions","directory"],"backgroundTag":"file-write-permission-denied","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}