uutils/coreutils · error
csplit-write-split-not-created
Error message
csplit-write-split-not-created
What it means
This panic occurs in csplit's output writer when a line is about to be written but no current split file writer has been created yet. csplit creates the writer lazily when a split file is opened; writing before any split is open means internal state is inconsistent (the writer was closed or never initialized). It is an unrecoverable panic rather than an io::Error because it indicates a bug in csplit's split-state machine, not user input.
Source
Thrown at src/uu/csplit/src/csplit.rs:303
/// The current split will not keep any of the read input lines.
fn as_dev_null(&mut self) {
self.dev_null = true;
}
/// Writes the line to the current split.
/// If `self.dev_null` is true, then the line is discarded.
///
/// # Errors
///
/// Some [`io::Error`] may occur when attempting to write the line.
fn writeln(&mut self, line: &str) -> io::Result<()> {
if !self.dev_null {
if let Some(ref mut current_writer) = self.current_writer {
let bytes = line.as_bytes();
current_writer.write_all(bytes)?;
self.size += bytes.len();
} else {
panic!("{}", translate!("csplit-write-split-not-created"))
}
}
Ok(())
}
/// Perform some operations after completing a split, i.e., either remove it
/// if the [`options::ELIDE_EMPTY_FILES`] option is enabled, or print how much bytes were written
/// to it if [`options::QUIET`] is disabled.
///
/// # Errors
///
/// Returns an error if flushing the writer fails.
fn finish_split(&mut self) -> Result<(), CsplitError> {
if !self.dev_null {
// Flush the writer to ensure all data is written and errors are detected
if let Some(ref mut writer) = self.current_writer {
let file_name = self.options.split_name.get(self.counter - 1);
writerView on GitHub (pinned to 9ff4114e82)
Solutions
- Update Rust coreutils to the latest version; if reproducible, file a bug with the exact csplit pattern arguments
- Check your csplit pattern/script: ensure the first operation opens a split before output is written
- Verify the output files were not removed/closed externally mid-run (e.g., another process deleting split files)
- As a workaround, redirect output to a directory you control and avoid patterns that address offsets before the first split
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
// panic, not Result — run csplit and check exit status
match Command::new("csplit").args([...]).status() {
Ok(s) if s.success() => { /* ok */ }
Ok(s) => eprintln!("csplit failed: {}", s),
Err(e) => eprintln!("spawn error: {e}"),
} Prevention
- Keep csplit patterns simple and ensure output is written only after a split is opened
- Use a maintained build of the coreutils implementation
- Avoid running concurrent csplit instances writing to the same output files
When it happens
Trigger: Internal: writeln() is invoked while self.current_writer is None and dev_null is false — i.e., do_to_line/do_to_match tries to emit output before a split file was opened or after it was finished/removed.
Common situations: Practically only hit with a buggy or patched csplit build, custom pattern scripts whose first operation is a write with no preceding split creation, or corrupted state when the output stream was removed mid-run.
Related errors
AI-assisted analysis of uutils/coreutils@9ff4114e82 (2026-08-31).
Data as JSON: /api/errors/2616965456b8514e.
Report an issue: GitHub.