apache/cassandra · error · IllegalArgumentException
%s exists but is not writable
Error message
%s exists but is not writable
What it means
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.
Source
Thrown at tools/stress/src/org/apache/cassandra/io/sstable/StressCQLSSTableWriter.java:409
return inDirectory(new File(directory));
}
/**
* The directory where to write the sstables (mandatory option).
* <p>
* This is a mandatory option.
*
* @param directory the directory to use, which should exist and be writable.
* @return this builder.
*
* @throws IllegalArgumentException if {@code directory} doesn't exist or is not writable.
*/
public Builder inDirectory(File directory)
{
if (!directory.exists())
throw new IllegalArgumentException(directory + " doesn't exists");
if (!directory.canWrite())
throw new IllegalArgumentException(directory + " exists but is not writable");
directoryList.add(directory);
return this;
}
/**
* A pre-instanciated ColumnFamilyStore
* <p>
* This is can be used in place of inDirectory and forTable
*
* @see #inDirectory(File)
*
* @param cfs the list of directories to use, which should exist and be writable.
* @return this builder.
*
* @throws IllegalArgumentException if a directory doesn't exist or is not writable.
*/
public Builder withCfs(ColumnFamilyStore cfs)View on GitHub (pinned to 88fd0f6a0e)
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.
Example fix
// before
builder.inDirectory(new File("/var/lib/cassandra/data")); // owned by cassandra user
// after
builder.inDirectory(new File(System.getProperty("java.io.tmpdir"), "sstable-out")); Defensive patterns
Strategy: validation
Validate before calling
File dir = new File(path);
if (!dir.canWrite()) throw new IllegalStateException("not writable: " + dir);
builder.inDirectory(dir); Try / catch
try { builder.inDirectory(dir); }
catch (IllegalArgumentException e) { throw new IllegalStateException("fix permissions on " + dir, e); } Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Permission denied" / "Failed to write" file errors: why a library can't write its files to disk (EACCES, EPERM, ENOSPC) and how to fix them — this error's family across 43 libraries.
Related errors
- Could not list files in {}
- Unable check disk space in '%s'. Perhaps the Cassandra user
- ; unable to start server
- Unable to create directory " + dir
- Dictionary file %s is not readable.
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/e826b24a706e6a74.
Report an issue: GitHub.