Ignoring files or folders for pull steps

Hi,

My Snap builds are taking increasingcly longer and occuppy a growing amount of space. I wondered why and found out. Here are logs:

:: 2025-11-04 19:00:36.268 Updating sources for appack (source changed)
:: 2025-11-04 19:00:36.268 execute action appack:Action(part_name='appack', step=Step.PULL, action_type=ActionType.UPDATE, reason='source changed', project_vars=ProjectVarInfo(root={}), properties=ActionProperties(changed_files=['.snapignore', 'rebuild_snap.sh', 'snapcraft.yaml'], changed_dirs=['.git', '.idea', 'AppPack']))
:: 2025-11-04 19:00:36.298 updated files: {'.snapignore', 'rebuild_snap.sh', 'snapcraft.yaml'}
:: 2025-11-04 19:00:36.299 updated directories: {'.idea', '.git', 'AppPack'}

The way I interpret the log is that because there has been changes for files and directories under the source of a part named appack, the part needs to be rebuilt.

parts:
  appack:
    plugin: rust
    source: . # .git, .idea are under this path
    build-packages:
      - ...
    stage-packages:
      - ...

Is there a way to tell snap to skip rebuilding the part, or even not to pull the .git and .idea folders? There are other custom folders that I want to exclude as well. For example, I have an assets folder. I do not want to rebuild the part if I make a change in this folder.

I came accross an ancient forum thread mentioning a .snapignore file that would do exactly that, but it doesn’t seem to have made it.

What is the recommended way to tackle the issue?

Thank you very much

Hi @yhu420 , I guess you mean this thread. The .snapignore proposal was never implemented.

Could you please try adding source-type: git below source: . and see if it improves the situation? From my understanding of the source code, the git source handler does not implement the “check if outdated” interface, whereas the local one (the default) does.

Using source-type: git does work, but only pulls after I commit. If I commit something only to my assets folder, it will also re-pull the entire repo and retrigger a build. So it gives more control over what is pulled, which is nice, but the issue persists.

For example, my source dir has 2 folders: src and assets, both in the same git repo.

The snapcraft.yaml has 2 parts: one build part for src and one with the dump plugin for assets.

After thinking a bit, I thought the best solution would follow this logic:

  • During the “build” part
    • Only re-pull/re-build if changes are detected under the src folder
    • changes under the assets folder are ignored (no re-pull/re-build if only assets are changed)
  • During the “dump” part
    • Only re-pull if changes under the assets folder
    • changes under the src folder are ignored (no re-pulling the assets if only source changes are made)

For the time being I just moved as much as I could out of the source folder. This is just a quality of life type of improvement I could use in my builds, for the time being it is manageable after some cleanup.

Thank you for reading, let me know if you have any thoughts on this

1 Like