← Back to issue list

Setting the snapcraft.yaml version field to 'git' produces undocumented and broken magic

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1769519
Type
issue
State
open
Author
~njmcphail
Labels
—
Created
Updated
Closed
—

Current evaluation

Documentation now includes version: git examples, but GitSource.generate_version() still lets tags containing characters such as underscores produce invalid snap versions that build successfully and fail installation.

Suggested action: keep open

Reason: Current snapcraft/utils.py still delegates version: git to GitSource.generate_version(); in craft-parts, unmatched git describe output is returned unchanged, so tags containing underscores can still produce invalid versions. Maintainer @kyrofa acknowledged workarounds using version-script or craftctl set-version, but no fix or removal is evidenced and version: git remains documented and supported.

Evaluated by: mr-cal-bot

Impact: 36 Quick Win: 14 Complexity: 38 Confidence: 92 Actionability: 64

Issue body

I've found that if the version: field in snapcraft.yaml is set to 'git', snapcraft does some magic where a mangled form of `git describe` is substituted into the version: field. This seems like a superb feature, although it is missing from the documentation. However, if the latest tag in the git repository contains invalid characters such as an underscore, the resultant snap will have an invalid version string and snap will refuse to install the package. Snapcraft itself does not produce an error. I'd suggest this piece of magic is either fixed (perhaps substituting '-' characters for invalid characters) or removed. (snapcraft version 2.42 on 16.04)

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 36
Quick Win: 14
Complexity: 38
Confidence: 92
Actionability: 64
keep open Documentation now includes version: git examples, but GitSource.generate_version() still lets tags containing characters such as underscores produce invalid snap versions that build successfully and fail installation.
stealth/space-bunny-alpha
Impact: 34
Quick Win: 14
Complexity: 47
Confidence: 94
Actionability: 76
keep open version: git remains broken for tags containing invalid snap version characters: craft-parts can return the tag unchanged, producing an artifact snap refuses to install.
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 11
Complexity: 40
Confidence: 70
Actionability: 60
keep open The `version: git` feature in snapcraft.yaml uses `git describe` output directly, which can contain invalid characters (e.g., underscores) causing snap installation failures. The feature is undocumented and lacks version sanitization.
qwen/qwen3.8-27b
Impact: 40
Quick Win: 24
Staleness: 95
Complexity: 40
Confidence: 55
Support Request: 15
close stale Snapcraft 2.42 (2018): setting version: git in snapcraft.yaml substitutes a mangled git describe output; tags with invalid chars (e.g. underscore) yield an invalid version that snap refuses to install, with no error. No maintainer interaction in 8+ years.
qwen/qwen3.6-35b-a3b
Staleness: 98
Complexity: 15
Confidence: 85
Support Request: 10
close stale Undocumented version git behavior in snapcraft breaks with invalid git tags. No maintainer response in 8+ years. Original report references snapcraft 2.42.
qwen/qwen3.6-35b-a3b
Staleness: 100
Complexity: 30
Confidence: 90
Support Request: 0
close stale Bug report regarding 'git' version parsing in snapcraft.yaml causing invalid snap versions with special characters in git tags. Issue is over 8 years old with no activity.
qwen3.6-35b-a3b-mtp-q6
Staleness: 98
Complexity: 20
Confidence: 90
Support Request: 10
close stale Setting version to 'git' in snapcraft.yaml triggers undocumented behavior and fails with invalid git tags. The issue is 8 years old, has no maintainer response or labels, and references an obsolete snapcraft version.

Update history

Date Change
created

Related issues

Issue Project State Summary Similarity
#1812633 "version: git" can produce version strings too long for snapd snapcraft (launchpad) closed Closed as superseded: version: git was deprecated in favor of craftctl set version after version-script was offered as the workaround for oversized git-derived versions.
71%