Snapcraft modifies binaries
Metadata
Current evaluation
Closed as expected behavior: Snapcraft 2.39+ intentionally rewrites classic-snap ELF binaries; use build-attributes: [no-patchelf] to preserve them.
Resolution: closed not a bug
Reason: Maintainer kyrofa confirmed that Patchelf intentionally modifies classic-snap binaries and directed the reporter to the per-part no-patchelf attribute. That opt-out was added by canonical/snapcraft PR #1987, commit 47d601fd2.
Evaluated by: mr-cal-bot
No scores available.
Issue body
When building with snapcraft 2.40.1 (or 2.39.2), the resulting snap file binaries differ by 4096 bytes from the original binaries that reside in the parts directory.
Under snapcraft 2.35, the resulting binaries from the parts directory match the snap exactly.
It's unclear if this behavior is limited to classic snaps or not, but I discovered this issue with the juju snap which is classic.
Here's comparing sha256sums for a binary for juju snap. Just to ensure there isn't something odd with unsquashfs, I also installed the snap and compared the mounted binary as well.
Under 2.39.2(or 2.40.1)
fafec8a06edb6e80069591436b92cfc84bc58aaee5b6992976f3b00b3851b2c0 squashfs-root/bin/jujud
58d50e028b7840aa2c1a25476037895588fa7241c51940da69367e4164ca8b9f parts/juju/install/bin/jujud
fafec8a06edb6e80069591436b92cfc84bc58aaee5b6992976f3b00b3851b2c0 /snap/juju/current/bin/jujud
du -b /snap/juju/current/bin/jujud squashfs-root/bin/jujud parts/juju/install/bin/jujud
121452768 /snap/juju/current/bin/jujud
121452768 squashfs-root/bin/jujud
121448672 parts/juju/install/bin/jujud
Redoing the build with snapcraft 2.35 I get matching binaries as expected.
58d50e028b7840aa2c1a25476037895588fa7241c51940da69367e4164ca8b9f squashfs-root/bin/jujud
58d50e028b7840aa2c1a25476037895588fa7241c51940da69367e4164ca8b9f parts/juju/install/bin/jujud.
58d50e028b7840aa2c1a25476037895588fa7241c51940da69367e4164ca8b9f /snap/juju/current/bin/jujud
du -b /snap/juju/current/bin/jujud squashfs-root/bin/jujud parts/juju/install/bin/jujud
121448672 /snap/juju/current/bin/jujud
121448672 squashfs-root/bin/jujud
121448672 parts/juju/install/bin/jujud
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed not a bug | Closed as expected behavior: Snapcraft 2.39+ intentionally rewrites classic-snap ELF binaries; use build-attributes: [no-patchelf] to preserve them. | |
| stealth/space-bunny-alpha | — | closed not a bug | Snapcraft 2.39+ intentionally rewrites classic-snap ELF binaries with patchelf; build-attribute no-patchelf preserves the original binaries. | |
| stealth/space-bunny-alpha | — | closed stale | Closed without resolution after eight years of inactivity. Snapcraft 2.39.2 and 2.40.1 reportedly added 4096 bytes to binaries versus 2.35, but no fix or maintainer explanation was recorded. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution after eight years of inactivity. Snapcraft 2.39.2 and 2.40.1 reportedly appended 4096 bytes to binaries versus version 2.35. No comments or fixes were provided, indicating the report was abandoned. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. Snapcraft 2.39.2 and 2.40.1 modified binaries by adding 4096 bytes, a regression from 2.35. The report was abandoned with no comments or fix applied. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. Snapcraft versions 2.39.2 and 2.40.1 unexpectedly appended 4096 bytes to binaries, a regression from 2.35. The report received no comments or patches and was abandoned. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without resolution. The binary modification issue in snapcraft 2.39.2 and 2.40.1 was not addressed, indicating the report was abandoned or superseded by newer releases. |
Update history
| Date | Change |
|---|---|
| created |
Related work
-
Related To:
canonical/snapcraft#1987
(confidence 98%)
Added the per-part option to disable Patchelf.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1831111 Snapcraft strips build ID | snapcraft (launchpad) | open | Snapcraft may strip GNU build IDs while PatchELF rewrites binaries, reportedly crashing Mesa's i965_dri.so; no-patchelf works around it, but the untriaged report lacks confirmation. |