{"record":{"id":"efd8a88906ce5dd1","repo":"denoland/deno","slug":"deno-json-version-version-cannot-be-used-as","errorCode":null,"errorMessage":"deno.json `version` \"{version}\" cannot be used as a Debian/RPM package version: it must start with a digit","messagePattern":"deno\\.json `version` \"(.+?)\" cannot be used as a Debian/RPM package version: it must start with a digit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/desktop.rs","lineNumber":3892,"sourceCode":"/// here: the package would build fine and only fail at `dpkg -i`/`rpm -i`\n/// time with an opaque \"invalid version\" error. Debian policy 5.6.12 requires\n/// the upstream version to start with a digit and restricts it to\n/// alphanumerics plus `. + - ~` (`:` and `-` being reserved as the epoch and\n/// revision separators, neither of which we emit); RPM's Version tag is\n/// similarly restricted and additionally forbids `-`.\n///\n/// 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>,","sourceCodeStart":3874,"sourceCodeEnd":3910,"githubUrl":"https://github.com/denoland/deno/blob/f7822238cab635a3a19f99f493f675fa81a7f9d8/cli/tools/desktop.rs#L3874-L3910","documentation":"This error is thrown while validating the `version` field of deno.json when it is used as a Debian/RPM package version. Debian and RPM both require package versions to start with a digit, so a config version beginning with a non-digit (e.g. `v1.2.3` or `beta-1`) is rejected. If no `version` is set in deno.json, a fixed LINUX_PACKAGE_VERSION default is used instead and no error occurs.","triggerScenarios":"Setting a `version` in deno.json that does not start with an ASCII digit (e.g. \"v1.0.0\", \"alpha1\") and running a desktop build targeting .deb/.rpm output.","commonSituations":"Prefixing versions with 'v' by habit (common Git-tag style), using pre-release labels at the start of the version string, or copying a version string from a tag name into deno.json.","solutions":["Change the deno.json `version` to start with a digit, e.g. strip a leading 'v'.","Remove the `version` field from deno.json to fall back to the default LINUX_PACKAGE_VERSION.","Move pre-release wording after the numeric part, e.g. \"1.0.0-alpha\" instead of \"alpha-1.0.0\"."],"exampleFix":"// deno.json\n// before\n{ \"version\": \"v1.2.3\" }\n// after\n{ \"version\": \"1.2.3\" }","handlingStrategy":"validation","validationCode":"const version = config.version;\nif (version && !/^[0-9]/.test(version)) {\n  throw new Error(`deno.json version \"${version}\" must start with a digit for Debian/RPM packaging`);\n}","typeGuard":"function isValidDebRpmVersionStart(version: string): boolean {\n  return /^[0-9]/.test(version);\n}","tryCatchPattern":"try {\n  await buildDesktopApp({ format: \"deb\" });\n} catch (err) {\n  if (String(err.message).includes(\"must start with a digit\")) {\n    console.error(\"Strip the leading 'v' or non-digit prefix from deno.json `version`.\");\n  } else {\n    throw err;\n  }\n}","preventionTips":["Never prefix deno.json `version` with 'v'; keep raw numeric versions.","Start versions with a digit when packaging for Debian/RPM.","Validate the version field in CI before running desktop packaging builds."],"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-14T05:17:10.506Z"}