{"record":{"id":"8d55d41c8eab763f","repo":"jordansissel/fpm","slug":"the-version-looks-invalid-for-debian-packages-deb","errorCode":null,"errorMessage":"The version looks invalid for Debian packages. Debian version field must contain only alphanumerics and . (period), + (plus), - (hyphen) or ~ (tilde). I have '#{@version}' which which isn't valid.","messagePattern":"The version looks invalid for Debian packages\\. Debian version field must contain only alphanumerics and \\. \\(period\\), \\+ \\(plus\\), - \\(hyphen\\) or ~ \\(tilde\\)\\. I have '#(.+?)' which which isn't valid\\.","errorType":"validation","errorClass":"FPM::InvalidPackageConfiguration","httpStatus":null,"severity":"error","filePath":"lib/fpm/package/deb.rb","lineNumber":332,"sourceCode":"      @name = @name.gsub(/[ ]/, \"-\")\n    end\n\n    return @name\n  end # def name\n\n  def prefix\n    return (attributes[:prefix] or \"/\")\n  end # def prefix\n\n  def version\n    if @version.kind_of?(String)\n      if @version.start_with?(\"v\") && @version.gsub(/^v/, \"\") =~ /^#{VERSION_FIELD_PATTERN}$/\n        logger.warn(\"Debian 'Version' field needs to start with a digit. I was provided '#{@version}' which seems like it just has a 'v' prefix to an otherwise-valid Debian version, I'll remove the 'v' for you.\")\n        @version = @version.gsub(/^v/, \"\")\n      end\n\n      if @version !~ /^#{VERSION_FIELD_PATTERN}$/\n        raise FPM::InvalidPackageConfiguration, \"The version looks invalid for Debian packages. Debian version field must contain only alphanumerics and . (period), + (plus), - (hyphen) or ~ (tilde). I have '#{@version}' which which isn't valid.\"\n      end\n    end\n\n    return @version\n  end\n\n  def input(input_path)\n    extract_info(input_path)\n    extract_files(input_path)\n  end # def input\n\n  def extract_info(package)\n    compression = `#{ar_cmd[0]} t #{package}`.split(\"\\n\").grep(/control.tar/).first.split(\".\").last\n    case compression\n      when \"gz\"\n        controltar = \"control.tar.gz\"\n        compression = \"-z\"\n      when \"bzip2\",\"bz2\"","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/jordansissel/fpm/blob/b6d77ba72a560b687723376a0e5115c3a92634ad/lib/fpm/package/deb.rb#L314-L350","documentation":"Debian policy requires the Version field to match [epoch:]upstream[-revision] using only alphanumerics and . + - ~ characters. fpm validates the version string in the deb output/input path (VERSION_FIELD_PATTERN); it first auto-strips a single leading 'v' with a warning, then raises FPM::InvalidPackageConfiguration if the remainder still fails the pattern.","triggerScenarios":"Passing --version (or a converted package carrying a version) containing characters outside [A-Za-z0-9.+~-], e.g. 1.2.3_beta (underscore), '1.0 rc1' (space), 1:2.0:x (extra colon), or 'v' followed by another invalid string. The auto-fix only handles exactly one leading 'v' before an otherwise valid version.","commonSituations":"Packaging git tags like v1.2.3-rc.1 (handled) vs v1.2.3+build 4 (space fails); upstream versions with underscores from dev releases; converting from gem/npm where versions like '2.0.0-beta.1' are valid but '2.0.0_beta' is not; double colons from templated version strings.","solutions":["Sanitize the version: replace invalid characters, typically _ -> ~ (Debian's ordering marker for pre-releases)","Strip a leading 'v' yourself (or rely on fpm's auto-strip once the rest is valid)","Format epochs and revisions correctly as 1:2.3.4-1 (integer epoch, single colon)","If converting from another package type, pass an explicit --version with a sanitized value"],"exampleFix":"# before\nfpm -s dir -t deb -n foo --version 1.2.3_beta .\n# -> version looks invalid for Debian packages\n\n# after\nfpm -s dir -t deb -n foo --version 1.2.3~beta .\n# leading v is auto-stripped: --version v1.2.3 also works","handlingStrategy":"validation","validationCode":"DEB_VERSION_RE = /\\A(?:(?:[0-9]+):)?(?:[A-Za-z0-9+~.-]+)(?:-[A-Za-z0-9+~.]+)?\\z/\n\ndef sanitize_deb_version(v)\n  v = v.sub(/\\Av/, '')                 # strip a single leading v\n  v.tr('_', '~')                       # common fix for dev releases like 1.2_3\nend\n\nabort \"invalid deb version '#{v}'\" unless sanitize_deb_version(v) =~ DEB_VERSION_RE","typeGuard":"def valid_deb_version?(v)\n  v = v.sub(/\\Av/, '')\n  !(v =~ /\\A(?:(?:[0-9]+):)?[A-Za-z0-9+~.-]+(?:-[A-Za-z0-9+~.]+)?\\z/).nil?\nend","tryCatchPattern":"begin\n  pkg.output(path)\nrescue FPM::InvalidPackageConfiguration => e\n  raise unless e.message =~ /version looks invalid/\n  pkg.version = sanitize_deb_version(pkg.version)   # strip v, _ -> ~\n  retry\nend","preventionTips":["Sanitize upstream versions (strip leading v, replace _ with ~) before passing --version","For gems/npm sources, pass an explicit sanitized --version instead of trusting carry-over","Keep epochs in the exact '1:2.3-4' shape; only one integer colon segment is allowed"],"tags":["fpm","deb","version","validation","packaging","debian-policy"],"backgroundTag":"invalid-version-string","analyzedSha":"b6d77ba72a560b687723376a0e5115c3a92634ad","analyzedAt":"2026-08-21T16:39:02.570Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}