{"record":{"id":"ff18084a509d2b10","repo":"sharkdp/hexyl","slug":"can-not-use-block-s-as-a-unit-to-specify-block","errorCode":null,"errorMessage":"can not use 'block(s)' as a unit to specify block size","messagePattern":"can not use 'block\\(s\\)' as a unit to specify block size","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":311,"sourceCode":"                let file = File::open(filename)?;\n\n                Input::File(file)\n            }\n        }\n        None => Input::Stdin(stdin.lock()),\n    };\n\n    if let Some(hex_number) = try_parse_as_hex_number(&opt.block_size) {\n        return hex_number\n            .map_err(|e| anyhow!(e))\n            .and_then(|x| {\n                PositiveI64::new(x).ok_or_else(|| anyhow!(\"block size argument must be positive\"))\n            })\n            .map(|_| ());\n    }\n    let (num, unit) = extract_num_and_unit_from(&opt.block_size)?;\n    if let Unit::Block { custom_size: _ } = unit {\n        return Err(anyhow!(\n            \"can not use 'block(s)' as a unit to specify block size\"\n        ));\n    };\n    let block_size = num\n        .checked_mul(unit.get_multiplier())\n        .ok_or_else(|| anyhow!(ByteOffsetParseError::UnitMultiplicationOverflow))\n        .and_then(|x| {\n            PositiveI64::new(x).ok_or_else(|| anyhow!(\"block size argument must be positive\"))\n        })?;\n\n    let skip_arg = opt\n        .skip\n        .as_ref()\n        .map(|s| {\n            parse_byte_offset(s, block_size).context(anyhow!(\n                \"failed to parse `--skip` arg {:?} as byte count\",\n                s\n            ))","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/sharkdp/hexyl/blob/6ecc29b9c8c84d08a7e860f7f69c22b113b480ea/src/main.rs#L293-L329","documentation":"The 'block' unit refers to the block size itself, so using it to *define* the block size would be circular. b3sum explicitly rejects --block-size values with the block unit.","triggerScenarios":"--block-size 2blocks, --block-size 1block, or any --block-size value whose parsed Unit is Unit::Block (including custom block sizes).","commonSituations":"Confusing --skip/--length style offsets (which may use block units) with the block-size definition; copying an offset expression into --block-size.","solutions":["Use a concrete byte unit for --block-size, e.g. --block-size 4096, 4k, 1MiB","Remove the 'blocks' suffix from the value","Use blocks units only in --skip/--length, not --block-size"],"exampleFix":"// before\nb3sum --block-size 4blocks file\n// after\nb3sum --block-size 4k file","handlingStrategy":"validation","validationCode":"case \"$bs\" in *block*|*blocks*) echo 'blocks unit not allowed for --block-size' >&2; exit 1;; esac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reserve block units for --skip/--length only","Always use byte units (k, M, GiB) for --block-size"],"tags":["cli","validation","units"],"backgroundTag":"invalid-argument-value","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"}