sharkdp/hexyl · error
failed to parse `--skip` arg
Error message
failed to parse `--skip` arg {:?} as byte count What it means
The --skip argument is parsed as a byte offset relative to the block size via parse_byte_offset; any parse failure is wrapped in context 'failed to parse `--skip` arg ... as byte count'.
Solutions
- Use a valid byte-count expression, e.g. --skip 1024, 4k, 2blocks, or -1024
- Check accepted unit suffixes and remove stray characters/spaces
- Read the inner parse error printed below the context message for the exact position that failed
Example fix
// before b3sum --skip 10kb file // after b3sum --skip 10k file
Defensive patterns
Strategy: validation
Validate before calling
[[ "$skip" =~ ^-?[0-9]+(k|KiB|M|MiB|G|GiB|blocks?)?$ ]] || { echo "bad --skip: $skip" >&2; exit 1; } Prevention
- Use only documented unit suffixes
- Avoid spaces and fractional values
- Read the nested parse error for the exact bad position
When it happens
Trigger: --skip with a malformed value such as --skip 12x, --skip abc, --skip 1.5, or a unit not recognized by parse_byte_offset.
Common situations: Typos in unit suffixes ('kib' vs 'KiB' style mistakes); passing human strings like '1MB ' with spaces; negative decimals; mixing up --skip with grep-like line semantics.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse `--length` arg
- ' ' is a directory.
- ByteOffsetParseError::UnitMultiplicationOverflow
- anyhow!(e)
- block size argument must be positive
AI-assisted analysis of sharkdp/hexyl@6ecc29b9c8 (2026-09-09).
Data as JSON: /api/errors/0f5edc9d3b22d3c6.
Report an issue: GitHub.
Appendix: source
Thrown at src/main.rs:326
}
let (num, unit) = extract_num_and_unit_from(&opt.block_size)?;
if let Unit::Block { custom_size: _ } = unit {
return Err(anyhow!(
"can not use 'block(s)' as a unit to specify block size"
));
};
let block_size = num
.checked_mul(unit.get_multiplier())
.ok_or_else(|| anyhow!(ByteOffsetParseError::UnitMultiplicationOverflow))
.and_then(|x| {
PositiveI64::new(x).ok_or_else(|| anyhow!("block size argument must be positive"))
})?;
let skip_arg = opt
.skip
.as_ref()
.map(|s| {
parse_byte_offset(s, block_size).context(anyhow!(
"failed to parse `--skip` arg {:?} as byte count",
s
))
})
.transpose()?;
let skip_offset = if let Some(ByteOffset { kind, value }) = skip_arg {
let value = value.into_inner();
reader
.seek(match kind {
ByteOffsetKind::ForwardFromBeginning | ByteOffsetKind::ForwardFromLastOffset => {
SeekFrom::Current(value)
}
ByteOffsetKind::BackwardFromEnd => SeekFrom::End(value.checked_neg().unwrap()),
})
.map_err(|_| {
anyhow!(
"Failed to jump to the desired input position. \View on GitHub (pinned to 6ecc29b9c8)