Possible bug in snapcraft with renamed source files

It happened to me second time over last month today. I have a C++ application. When changing one of the source file names (say from sample.cpp to sample2.cpp) and successfully re-building the application locally with make utility, snapcraft fails to rebuild it. It shows an error pointing to the old (now missing) source filename. I do my file renaming with “git mv”, command, so it can be related possibly to git, but maybe not. When I do “snapcraft clean” trying to fix it, typically the issue persists for some time (hours). The next day I do a fresh build after “snapcraft clean” and magically it works.

Very annoying. First time I thought it was just an odd one-time case, but it just happened again.

This is unexpected since snapcraft clean removes the entire build instance. I’ve tried to reproduce this problem using a local source and it fails if I just run snapcraft again, but it works as expected if I run snapcraft clean to remove the build container before running snapcraft. Is there any special procedure I should follow to reproduce your scenario?

Have you used git for project source control? Possibly it’s related to git, not just file renaming. Nothing special in my case.

Is it a single-part project with a git source?


app-assets: source: . plugin: dump stage: - fonts - images - sounds

desktop-glib-only: source: https://github.com/ubuntu/snapcraft-desktop-helpers.git source-subdir: glib-only plugin: make build-packages: - libglib2.0-dev stage-packages: - libglib2.0-bin

app-name: after: - desktop-glib-only plugin: make source: . build-packages: - g++ - make - libboost-program-options-dev - libsdl2-dev - libsdl2-ttf-dev

I see an odd thing here, you have two parts (app-assets and app-name) sharing the same source (.). This is not usual, but it doesn’t seem directly connected to the initial problem because regardless of what’s being done, the build container is deleted and a new one is created and re-populated with the sources you specified.

However, if you’re also building the sources locally, make sure to clean them before running Snapcraft, otherwise all the files generated in the build process will also be considered as part of the project (because you have source: .) and will be copied to the build instance. Then when the build happens inside the container the object files will already be there, even if the container is recreated.

So I am guessing if I move my source into a separate ./src directory or move assets making some common parent folder other than dot, the issue should go away? When I build the app locally, the only file that is being created is the executable (no temp files), I am guessing that snapcraft is smart enough not to include the locally built executable into itself.

Thank you for looking into it.

Everything that’s inside the directory that source: points to will be considered part of the source, Snapcraft doesn’t filter out additional files created locally because it doesn’t actually know what is the original source and what was generated during a local build process.