{"record":{"id":"ec32c1826cd2bd03","repo":"sharkdp/hexyl","slug":"failed-to-jump-to-the-desired-input-position-this","errorCode":null,"errorMessage":"Failed to jump to the desired input position. This could be caused by a negative offset that is too large or by an input that is not seek-able (e.g. if the input comes from a pipe).","messagePattern":"Failed to jump to the desired input position\\. This could be caused by a negative offset that is too large or by an input that is not seek-able \\(e\\.g\\. if the input comes from a pipe\\)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":343,"sourceCode":"        .map(|s| {\n            parse_byte_offset(s, block_size).context(anyhow!(\n                \"failed to parse `--skip` arg {:?} as byte count\",\n                s\n            ))\n        })\n        .transpose()?;\n\n    let skip_offset = if let Some(ByteOffset { kind, value }) = skip_arg {\n        let value = value.into_inner();\n        reader\n            .seek(match kind {\n                ByteOffsetKind::ForwardFromBeginning | ByteOffsetKind::ForwardFromLastOffset => {\n                    SeekFrom::Current(value)\n                }\n                ByteOffsetKind::BackwardFromEnd => SeekFrom::End(value.checked_neg().unwrap()),\n            })\n            .map_err(|_| {\n                anyhow!(\n                    \"Failed to jump to the desired input position. \\\n                     This could be caused by a negative offset that is too large or by \\\n                     an input that is not seek-able (e.g. if the input comes from a pipe).\"\n                )\n            })?\n    } else {\n        0\n    };\n\n    let parse_byte_count = |s| -> Result<u64> {\n        Ok(parse_byte_offset(s, block_size)?\n            .assume_forward_offset_from_start()?\n            .into())\n    };\n\n    let mut reader = if let Some(ref length) = opt.length {\n        let length = parse_byte_count(length).context(anyhow!(\n            \"failed to parse `--length` arg {:?} as byte count\",","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/sharkdp/hexyl/blob/6ecc29b9c8c84d08a7e860f7f69c22b113b480ea/src/main.rs#L325-L361","documentation":"After computing the seek target from --skip, reader.seek() fails; b3sum replaces the raw io::Error with this explanation: either the negative offset underflows before the start of input, or the input is not seekable (pipe/stdin).","triggerScenarios":"Using --skip with a negative value larger than bytes already read (SeekFrom::End underflow), or using a positive skip when input is stdin/a pipe where seek is unsupported.","commonSituations":"`cat file | b3sum --skip 100` (pipes are not seekable); `b3sum --skip -999999 file` where the offset precedes file start; reading from process substitution.","solutions":["Provide a real file instead of piped stdin when using --skip","Use a non-negative --skip when input comes from a pipe","Reduce the magnitude of negative skips so they stay within the input length","Buffer the input to a temp file first, then skip"],"exampleFix":"// before\ncat file.bin | b3sum --skip 100\n// after\nb3sum --skip 100 file.bin","handlingStrategy":"fallback","validationCode":"[ -t 0 ] || [ -n \"$input_file\" ] || { echo '--skip requires a seekable file for positive offsets' >&2; exit 1; }","typeGuard":"fn is_seekable(f: &File) -> bool { f.seek(SeekFrom::Current(0)).is_ok() }","tryCatchPattern":"match result { Err(e) if msg.contains('not seek-able') => buffer_to_temp_file_then_retry(), Err(e) => propagate(e) }","preventionTips":["Don't pipe input when using --skip","Keep negative skips within input length","Spool pipes to temp files before seeking"],"tags":["io","seek","stdin"],"backgroundTag":"unsupported-operation","analyzedSha":"6ecc29b9c8c84d08a7e860f7f69c22b113b480ea","analyzedAt":"2026-09-09T22:34:15.450Z","contentChangedAt":"2026-09-09T22:34:15.450Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}