Morganamilo/paru · error · anyhow::Error

value can not contain null bytes

Error message

value can not contain null bytes

What it means

parse_env rejects environment variable values containing a NUL ('\0') byte. Environment values passed to child processes via set_var/execve cannot contain NUL, so the library validates the value before storing it and exporting it with set_var.

Solutions

  1. Fix or remove the [env] entry containing the null byte (grep -P '\x00' paru.conf)
  2. Regenerate the value using newline-terminated output instead of NUL-delimited output
  3. Validate the config file as clean UTF-8 text
Defensive patterns

Strategy: validation

Validate before calling

fn valid_env_value(value: &str) -> bool {
    !value.contains('\0')
}

Prevention

When it happens

Trigger: A value parsed from the config [env] section contains '\0', e.g. a corrupted config file or wrongly interpolated binary content.

Common situations: Config files corrupted by binary writes; env values generated from program output containing NULs (e.g. find -print0 output pasted raw).

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.

Related errors


AI-assisted analysis of Morganamilo/paru@9ac3578807 (2026-09-12). Data as JSON: /api/errors/0be3c2d5172cc113. Report an issue: GitHub.

Appendix: source

Thrown at src/config.rs:992

        match key {
            "Url" => repo.source.set_url(Url::parse(value?)?),
            "Path" => repo.source.set_path(value?.to_string()),
            "Depth" => repo.depth = value?.parse()?,
            "SkipReview" => repo.skip_review = true,
            "GenerateSrcinfo" => repo.force_srcinfo = true,
            _ => eprintln!("{}", tr!("error: unknown option '{}' in repo", key)),
        }

        Ok(())
    }

    fn parse_env(&mut self, key: &str, value: Option<&str>) -> Result<()> {
        let value = value.context(tr!("key can not be empty"))?;

        ensure!(!key.is_empty(), tr!("key can not be empty"));
        ensure!(!key.contains('\0'), tr!("key can not contain null bytes"));
        ensure!(
            !value.contains('\0'),
            tr!("value can not contain null bytes")
        );

        self.env.push((key.to_owned(), value.to_string()));
        set_var(key, value);
        Ok(())
    }

    fn parse_bin(&mut self, key: &str, value: Option<&str>) -> Result<()> {
        let value = value
            .map(|s| s.to_string())
            .ok_or_else(|| anyhow!(tr!("key can not be empty")))?;

        let split = value.split_whitespace().map(|s| s.to_string());

        match key {
            "Makepkg" => self.makepkg_bin = value,

View on GitHub (pinned to 9ac3578807)