← Back to issue list

Using (source-type: git; source: .) does not seem to ever realise files have changed, snap rebuild caches code changes

View original Github issue

Metadata

Project
snapcraft
Number
#4883
Type
issue
State
open
Author
lathiat
Labels
Created
Updated
Closed

Current evaluation

Snapcraft with source-type: git and source: . never detects local file changes, reusing cached source instead of re-pulling. Maintainer confirmed behavior is incorrect but suggested using source-type: local as workaround. Issue is 794 days old with no fix.

Suggested action: keep open

Reason: Maintainer @lengau explicitly acknowledged the behavior is incorrect ('this behaviour is still incorrect') while suggesting source-type: local as a workaround. The issue is a genuine bug in craft-parts' GitSource where local git sources don't track file changes. The GitSource._pull_existing() method uses git fetch/reset which won't detect uncommitted local changes, and the checksum mechanism likely doesn't account for working tree modifications. This is a real bug affecting developers using local git sources, though the workaround (source-type: local) mitigates it. The issue is stale (794 days, last activity 776 days ago) but the underlying bug in craft-parts GitSource appears to still exist based on current code inspection.

Impact: 55 Quick Win: 33.0 Staleness: 75 Complexity: 40 Confidence: 70 Support Request: 10

Issue body

### Bug Description It seems that when you specify `source-type: git` and `source: .` to use the git source from the local directory, that snapcraft never notices a change to the source and will re-used the cached source. This results in a re-built snap that has not integrated local code changes, which is very surprising. I ran into this while working on the Simplestreams Snap (https://git.launchpad.net/simplestreams) which currently does this. I would make a local change to the bin/sstream-query file, re-run `snapcraft` and then the change would not be included. The same is true if I actually make a git commit with the change. It seems that the PULL stage is presumed clean and is not re-run as the `override-pull` steps to set the version from the git hash also don't seem to get re-run, even if I've made an actual commit that changes it's output. Additionally, if you make a change to the override-pull script to force it to re-run the step then it will pickup both committed and non-committed changes in that case. So it doesn't seem to be a case of it comparing the git hash or ignore local changes. If you change the source tree to use `source-type: local` this doesn't happen, and changing a file (whether committed or not) results in the pull stage re-running and the source not being cached. Ideally this behaviour would be fixed, or possibly we should disallow this to stop people shooting themselves in the foot. ### To Reproduce 1. `git clone https://git.launchpad.net/simplestreams` 2. Apply new snapcraft.yaml changes ``` patch -Np1 <<<EOF diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 75ac11a362ea..5b85628b84a9 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: simplestreams -base: core18 +base: core22 adopt-info: simplestreams summary: Library and tools for using Simple Streams data description: Library and tools for using Simple Streams data @@ -41,11 +41,8 @@ apps: parts: simplestreams: plugin: python - python-version: python3 source: . source-type: git - constraints: - - https://raw.githubusercontent.com/openstack/requirements/stable/ussuri/upper-constraints.txt python-packages: - python-glanceclient - python-keystoneclient @@ -58,8 +55,7 @@ parts: - libssl-dev - libxml2-dev - libxslt1-dev - override-build: | - snapcraftctl build - last_release="$(git tag -l --sort=version:refname | grep -v ubuntu | tail -1)" - current_shorthash="$(git log --format="%h" | head -1)" - snapcraftctl set-version "${last_release}-${current_shorthash}" + override-pull: | + craftctl default + TAG=$(git describe --tags --abbrev=10) + craftctl set version="${TAG#v}" EOF ``` 3. Build the snap `snapcraft` 5. Modify bin/sstream-query ``` patch -Np1 <<<EOF diff --git a/bin/sstream-query b/bin/sstream-query index 65343173889c..62cbe208a16d 100755 --- a/bin/sstream-query +++ b/bin/sstream-query @@ -28,6 +28,8 @@ import pprint import signal import sys +# Test change + FORMAT_PRETTY = "PRETTY" FORMAT_JSON = "JSON" DEFAULT_KEYRING = "/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg" ``` 6. Re-run snapcraft ``` rm *.snap snapcraft ``` 7. Install the snap `snap install --dangerous ./simplestreams_*.snap` 9. Check if the file matches `diff /snap/simplestreams/current/bin/sstream-query ./bin/sstream-query` ### Environment Snapcraft: 8.2.12 (12024) tracking latest/stable Ubuntu 22.04 Build Provider: LXD ### snapcraft.yaml ```shell name: simplestreams base: core22 adopt-info: simplestreams summary: Library and tools for using Simple Streams data description: Library and tools for using Simple Streams data grade: stable confinement: strict layout: /usr/share/keyrings: bind: $SNAP/usr/share/keyrings apps: sstream-mirror: command: bin/sstream-mirror plugs: - network - home sstream-mirror-glance: command: bin/sstream-mirror-glance plugs: - network - home sstream-query: command: bin/sstream-query plugs: - network - home sstream-sync: command: bin/sstream-sync plugs: - network - home json2streams: command: bin/json2streams plugs: - network - home parts: simplestreams: plugin: python source: . source-type: git python-packages: - python-glanceclient - python-keystoneclient - python-swiftclient stage-packages: - gpgv - ubuntu-keyring build-packages: - libffi-dev - libssl-dev - libxml2-dev - libxslt1-dev override-pull: | craftctl default TAG=$(git describe --tags --abbrev=10) craftctl set version="${TAG#v}" ``` ### Relevant log output ```shell N/A ``` ### Additional context _No response_

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 55
Quick Win: 33.0
Staleness: 75
Complexity: 40
Confidence: 70
Support Request: 10
keep open Snapcraft with source-type: git and source: . never detects local file changes, reusing cached source instead of re-pulling. Maintainer confirmed behavior is incorrect but suggested using source-type: local as workaround. Issue is 794 days old with no fix.
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 50
Confidence: 75
Support Request: 10
needs triage Unlabelled bug report detailing snapcraft caching issues with source-type: git and source: . Requires maintainer assessment to verify current behavior and assign priority.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 65
Confidence: 80
Support Request: 10
close stale Snapcraft fails to detect source changes when using source-type: git with source: ., causing cached builds to ignore local modifications. Issue has been inactive for over a year with a maintainer-provided workaround.
qwen3.6-35b-a3b-mtp-q6
Staleness: 95
Complexity: 40
Confidence: 70
Support Request: 10
close stale Bug where source-type git with source dot incorrectly caches local changes, skipping rebuilds. Maintainer acknowledges the flaw and suggests source-type local as a workaround. Issue remains open, unlabeled, and awaiting triage.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#1860526 source-type breaks remote-build snapcraft (launchpad) open snapcraft remote-build fails when source-type is git because the source directory differs from the working directory, causing go dep to fail. The remote-build command has since been removed from snapcraft, making this issue obsolete.
72%