denoland/deno · error

deno.json `version` "{version}" cannot be used as a Debian/R

Error message

deno.json `version` "{version}" cannot be used as a Debian/RPM package version: the character '{c}' is not allowed (only alphanumerics, '.', '+', '-' and '~')

What it means

This error is thrown when the deno.json `version` contains a character that Debian/RPM package versions forbid. Only ASCII alphanumerics and `.`, `+`, `-`, `~` are permitted; any other character (e.g. `_`, spaces, `/`) aborts the package build. Once validated, hyphens are normalized to `~` for the package version.

Source

Thrown at cli/tools/desktop.rs:3899

/// The one transformation applied is `-` → `~`: neither format reads `-` in
/// the upstream-version position with the meaning users expect from a semver
/// prerelease, while both order `~` as "less than the release" — the semver
/// intent.
fn linux_package_version(
  config_version: Option<&str>,
) -> Result<String, AnyError> {
  let Some(version) = config_version else {
    return Ok(LINUX_PACKAGE_VERSION.to_string());
  };
  if !version.starts_with(|c: char| c.is_ascii_digit()) {
    bail!(
      "deno.json `version` \"{version}\" cannot be used as a Debian/RPM package version: it must start with a digit"
    );
  }
  if let Some(c) = version.chars().find(|c| {
    !(c.is_ascii_alphanumeric() || matches!(c, '.' | '+' | '-' | '~'))
  }) {
    bail!(
      "deno.json `version` \"{version}\" cannot be used as a Debian/RPM package version: the character '{c}' is not allowed (only alphanumerics, '.', '+', '-' and '~')"
    );
  }
  Ok(version.replace('-', "~"))
}

/// Map a target triple (or the host arch when `target` is None) to a Debian
/// architecture name. Debian arch names differ from the triple's leading
/// component (`x86_64` → `amd64`, `aarch64` → `arm64`).
fn debian_arch_for_target(
  target: Option<&str>,
) -> Result<&'static str, AnyError> {
  let arch = target
    .and_then(|t| t.split('-').next())
    .unwrap_or(std::env::consts::ARCH);
  match arch {
    "x86_64" => Ok("amd64"),
    "aarch64" => Ok("arm64"),

View on GitHub (pinned to f7822238ca)

Solutions

  1. Replace the offending character with an allowed one, e.g. `_` -> `.` or `-`, and re-run the build.
  2. Restrict the version to `[0-9A-Za-z.+-~]` characters before building.
  3. Remove the `version` field from deno.json to use the default Linux package version.

Example fix

// deno.json
// before
{ "version": "1.2.3_beta+exp_1" }
// after
{ "version": "1.2.3-beta+exp.1" }
Defensive patterns

Strategy: validation

Validate before calling

const version = config.version;
if (version && /[^0-9A-Za-z.+-~]/.test(version)) {
  const bad = version.match(/[^0-9A-Za-z.+-~]/)![0];
  throw new Error(`deno.json version "${version}" contains invalid character '${bad}' for Debian/RPM`);
}

Type guard

function isValidDebRpmVersion(version: string): boolean {
  return /^[0-9][0-9A-Za-z.+-~]*$/.test(version);
}

Try / catch

try {
  await buildDesktopApp({ format: "rpm" });
} catch (err) {
  if (String(err.message).includes("is not allowed")) {
    console.error("Replace disallowed characters in deno.json `version` with '.', '-', '+' or '~'.");
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Setting a deno.json `version` containing a disallowed character (underscore, whitespace, slash, etc.) and running a desktop build targeting .deb/.rpm output.

Common situations: Using versions like "1.2.3_beta" or "1.2.3 (dev)" copied from a build string or semantic-version with underscores; pasting a full version with metadata separators like "+build.1_bad" containing invalid chars.

Related errors


AI-assisted analysis of denoland/deno@f7822238ca (2026-08-29). Data as JSON: /api/errors/f03c94c90ad7b282. Report an issue: GitHub.