{"record":{"id":"f03c94c90ad7b282","repo":"denoland/deno","slug":"deno-json-version-version-cannot-be-used-as-f03c94","errorCode":null,"errorMessage":"deno.json `version` \"{version}\" cannot be used as a Debian/RPM package version: the character '{c}' is not allowed (only alphanumerics, '.', '+', '-' and '~')","messagePattern":"deno\\.json `version` \"(.+?)\" cannot be used as a Debian/RPM package version: the character '(.+?)' is not allowed \\(only alphanumerics, '\\.', '\\+', '-' and '~'\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/desktop.rs","lineNumber":3899,"sourceCode":"/// The one transformation applied is `-` → `~`: neither format reads `-` in\n/// the upstream-version position with the meaning users expect from a semver\n/// prerelease, while both order `~` as \"less than the release\" — the semver\n/// intent.\nfn linux_package_version(\n  config_version: Option<&str>,\n) -> Result<String, AnyError> {\n  let Some(version) = config_version else {\n    return Ok(LINUX_PACKAGE_VERSION.to_string());\n  };\n  if !version.starts_with(|c: char| c.is_ascii_digit()) {\n    bail!(\n      \"deno.json `version` \\\"{version}\\\" cannot be used as a Debian/RPM package version: it must start with a digit\"\n    );\n  }\n  if let Some(c) = version.chars().find(|c| {\n    !(c.is_ascii_alphanumeric() || matches!(c, '.' | '+' | '-' | '~'))\n  }) {\n    bail!(\n      \"deno.json `version` \\\"{version}\\\" cannot be used as a Debian/RPM package version: the character '{c}' is not allowed (only alphanumerics, '.', '+', '-' and '~')\"\n    );\n  }\n  Ok(version.replace('-', \"~\"))\n}\n\n/// Map a target triple (or the host arch when `target` is None) to a Debian\n/// architecture name. Debian arch names differ from the triple's leading\n/// component (`x86_64` → `amd64`, `aarch64` → `arm64`).\nfn debian_arch_for_target(\n  target: Option<&str>,\n) -> Result<&'static str, AnyError> {\n  let arch = target\n    .and_then(|t| t.split('-').next())\n    .unwrap_or(std::env::consts::ARCH);\n  match arch {\n    \"x86_64\" => Ok(\"amd64\"),\n    \"aarch64\" => Ok(\"arm64\"),","sourceCodeStart":3881,"sourceCodeEnd":3917,"githubUrl":"https://github.com/denoland/deno/blob/f7822238cab635a3a19f99f493f675fa81a7f9d8/cli/tools/desktop.rs#L3881-L3917","documentation":"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.","triggerScenarios":"Setting a deno.json `version` containing a disallowed character (underscore, whitespace, slash, etc.) and running a desktop build targeting .deb/.rpm output.","commonSituations":"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.","solutions":["Replace the offending character with an allowed one, e.g. `_` -> `.` or `-`, and re-run the build.","Restrict the version to `[0-9A-Za-z.+-~]` characters before building.","Remove the `version` field from deno.json to use the default Linux package version."],"exampleFix":"// deno.json\n// before\n{ \"version\": \"1.2.3_beta+exp_1\" }\n// after\n{ \"version\": \"1.2.3-beta+exp.1\" }","handlingStrategy":"validation","validationCode":"const version = config.version;\nif (version && /[^0-9A-Za-z.+-~]/.test(version)) {\n  const bad = version.match(/[^0-9A-Za-z.+-~]/)![0];\n  throw new Error(`deno.json version \"${version}\" contains invalid character '${bad}' for Debian/RPM`);\n}","typeGuard":"function isValidDebRpmVersion(version: string): boolean {\n  return /^[0-9][0-9A-Za-z.+-~]*$/.test(version);\n}","tryCatchPattern":"try {\n  await buildDesktopApp({ format: \"rpm\" });\n} catch (err) {\n  if (String(err.message).includes(\"is not allowed\")) {\n    console.error(\"Replace disallowed characters in deno.json `version` with '.', '-', '+' or '~'.\");\n  } else {\n    throw err;\n  }\n}","preventionTips":["Restrict deno.json `version` to [0-9A-Za-z.+-~] characters.","Replace underscores or spaces with '.' or '-' in version strings.","Run a lint/CI check on the version field before packaging."],"tags":["cli","desktop","packaging","version-validation","linux"],"backgroundTag":"invalid-package-version","analyzedSha":"f7822238cab635a3a19f99f493f675fa81a7f9d8","analyzedAt":"2026-08-29T08:55:39.519Z","contentChangedAt":"2026-08-29T08:55:39.519Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}