An empty snap directory ends up in the snap

Bug #1660890 reported by Leo Arias
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Fix Released
Kyle Fazzari

Bug Description

The snap directory is not filtered out of the snap. I think this is almost never the intended behaviour.

$ snapcraft init
$ snapcraft
$ ls prime/
meta snap

This is clearly wrong, the snap directory is empty. But I think this is also wrong:

$ snapcraft init
$ touch snap/file
$ snapcraft
$ ls prime/snap/

Revision history for this message
Leo Arias (elopio) wrote :

I think that if you want to include the file, you should be explicit and do something like:

    source: snap
    plugin: dump

However, this could be confusing as the file will end up in the root of the snap, and somebody might expect it in the snap directory. That's more related to

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

Migrating the snap directory into the final snap is actually by design (although it shouldn't be empty-- this is likely due to the fact that copying the snapcraft.yaml is behind a feature flag if I recall correctly). It's done so that the snapcraft.yaml can be used to rebuild the snap, and it's also done as that's where hooks are installed into (then snapcraft can generate wrappers for the real hooks).

Kyle Fazzari (kyrofa)
summary: - The snap directory ends up in the snap
+ An empty snap directory ends up in the snap
Revision history for this message
Olivier Tilloy (osomon) wrote :

Is it expected that the gui/ and plugins/ dirs end up in the snap directory too?

Also, if I use the snap directory as a source for a part using dump to copy files to the root of the snap, I don’t want those files to be embedded in the snap in the snap/ directory.

It looks like snapcraft is just recursively copying the contents of the snap/ directory (except for snapcraft.yaml, strangely enough). Maybe the behaviour should be reversed: it should copy only snapcraft.yaml and relevant files?

Revision history for this message
Cris Dywan (kalikiana) wrote :

I much like the idea of snapcraft.yaml being part of the snap to see how it was built - but I second Olivier, I don't want my snap to include all sources needed to build it, that would be like merging -dev(el) packages with binary packages in a Debian(Fedora) world.

Revision history for this message
Mark Shuttleworth (sabdfl) wrote : Re: [Bug 1660890] Re: An empty snap directory ends up in the snap

I think we want a culture that snaps by default are lean. Empty
directories and boilerplate info are waste, so they should not be in by
default. If there is an empty gui directory, don't put it in the snap.

I think the inclusion of snapcraft.yaml (on its own) is interesting, but
not by default unless there is something in the snapcraft.yaml that says
to do so. For a large number of snaps this would be considered a leak of
sensitive information. So let's add a single directive in snapcraft.yaml
to govern whether such "how to build me yourself" information shows up
in the final snap.


Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

Imho, I'm agree in not including anything extra not really needed for snap to work. If needed to include plugins, snapcraft or whatever, how about having a kind of "metasnap" with only all that info? (generated explicitly by a snapcraft param, for instance). Not sure if that is worth...

Changed in snapcraft:
importance: Undecided → Medium
assignee: nobody → Sergio Schvezov (sergiusens)
status: New → Triaged
milestone: none → 2.28
Changed in snapcraft:
milestone: 2.28 → none
Changed in snapcraft:
milestone: none → 2.43
Kyle Fazzari (kyrofa)
Changed in snapcraft:
assignee: Sergio Schvezov (sergiusens) → Kyle Fazzari (kyrofa)
status: Triaged → In Progress
Revision history for this message
Kyle Fazzari (kyrofa) wrote :
Changed in snapcraft:
status: In Progress → Fix Committed
Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.