{"record":{"id":"7434d723bc581d12","repo":"uutils/coreutils","slug":"split-error-file-descriptor-limit","errorCode":null,"errorMessage":"split-error-file-descriptor-limit","messagePattern":"split-error-file-descriptor-limit","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/uu/split/src/split.rs","lineNumber":890,"sourceCode":"            }\n\n            // Could have hit system limit for open files.\n            // Try to close one previously instantiated writer first\n            for (i, out_file) in self.iter_mut().enumerate() {\n                if i != idx\n                    && let Some(writer) = out_file.maybe_writer.as_mut()\n                {\n                    writer.flush()?;\n                    out_file.maybe_writer = None;\n                    out_file.is_new = false;\n                    count += 1;\n\n                    // And then try to instantiate the writer again\n                    continue 'loop1;\n                }\n            }\n\n            // If this fails - give up and propagate the error\n            uucore::show_error!(\n                \"{}\",\n                translate!(\"split-error-file-descriptor-limit\", \"count\" => count)\n            );\n            return Err(maybe_writer.err().unwrap().into());\n        }\n    }\n\n    fn get_writer(&mut self, idx: usize, settings: &Settings) -> UResult<&mut Writer> {\n        if self[idx].maybe_writer.is_some() {\n            Ok(self[idx].maybe_writer.as_mut().unwrap())\n        } else {\n            // Writer was not instantiated upfront or was temporarily closed due to system resources constraints.\n            // Instantiate it and record for future use.\n            self.instantiate_writer(idx, settings)\n        }\n    }\n}","sourceCodeStart":872,"sourceCodeEnd":908,"githubUrl":"https://github.com/uutils/coreutils/blob/92995feca29e324a7c559ede91db81c32d9f5d59/src/uu/split/src/split.rs#L872-L908","documentation":"split's instantiate_writer retries writer creation when it hits the open file-descriptor limit, closing writers and retrying. If after exhausting retries the writer still cannot be created, it prints the localized 'split-error-file-descriptor-limit' message (with the chunk count) and returns the underlying error.","triggerScenarios":"`split -n <count>` (or -l/-b chunking) requesting more simultaneous output files than the process's RLIMIT_NOFILE allows, and the retry loop still cannot open writers.","commonSituations":"splitting a large file into thousands of chunks; containers with low nofile ulimit (e.g. 256 or 1024); CI environments with restrictive fd limits.","solutions":["Raise the fd limit: `ulimit -n 65536` before running split","Reduce the number of chunks with a smaller -n/-l/-b count","Use numeric-suffixes/sequential output into fewer files or pipe through a compressor to limit open files"],"exampleFix":"// before\nsplit -n 5000 bigfile\n// after\nulimit -n 65536 && split -n 5000 bigfile","handlingStrategy":"retry","validationCode":"// pre-check fd headroom (unix)\nfn can_open_n_files(n: usize) -> bool {\n    let lim = unsafe { let mut r: libc::rlimit = std::mem::zeroed(); libc::getrlimit(libc::RLIMIT_NOFILE, &mut r); r.rlim_cur as usize };\n    n + 16 < lim\n}","typeGuard":null,"tryCatchPattern":"match split(input, args) {\n    Err(e) if e.to_string().contains(\"file-descriptor-limit\") => {\n        eprintln!(\"raise `ulimit -n` or reduce chunk count\");\n    }\n    r => r?,\n}","preventionTips":["Raise RLIMIT_NOFILE before chunk-heavy operations","Bound chunk counts to available fds (keep a safety margin)","Stream chunks into compressors instead of keeping thousands of files open"],"tags":["split","file-descriptor","ulimit","io"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"92995feca29e324a7c559ede91db81c32d9f5d59","analyzedAt":"2026-09-20T12:39:35.476Z","contentChangedAt":"2026-09-20T12:39:35.476Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}