Snapcraft fails to prime part containg device files
Metadata
Current evaluation
Closed without a direct fix. Snapcraft crashes when priming parts with device files, throwing an OSError during ELF detection. The bug was likely abandoned or resolved in newer Snapcraft versions.
Suggested action: —
No scores available.
Issue body
I was recently working on a patch to the core snap, and ran into some travis CI failures that looks like a Snapcraft bug:
https://travis-ci.org/snapcore/core/builds/348051901
This appears to be using snapcraft 2.39.3 from xenial-updates, and the end of the log shows the following failure:
File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 513, in prime
elf_files = elf.get_elf_files(self.primedir, snap_files)
File "/usr/lib/python3/dist-packages/snapcraft/internal/elf.py", line 568, in get_elf_files
if ElfFile.is_elf(path):
File "/usr/lib/python3/dist-packages/snapcraft/internal/elf.py", line 152, in is_elf
with open(path, 'rb') as bin_file:
OSError: [Errno 6] No such device or address: '/build/prime/dev/midi01'
It is trying to open a device file to check whether it looks like an ELF binary. Maybe it should be doing an "os.path.isfile()" check before hand, to check whether it has a regular file or not?
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Closed without a direct fix. Snapcraft crashes when priming parts with device files, throwing an OSError during ELF detection. The bug was likely abandoned or resolved in newer Snapcraft versions. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without documented resolution. Snapcraft crashes when priming device files by attempting to read them as ELF binaries. The suggested os.path.isfile guard was never implemented or verified in the thread. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution, likely abandoned. Snapcraft crashed when priming parts containing device files because it attempted to open them as ELF binaries. A file type check was suggested to prevent the error. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without documented resolution. Snapcraft crashed when priming device files by attempting to read them as ELF binaries. No patch or workaround was applied. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1838098 snapcraft prime fails if it finds an invalid ELF file | snapcraft (launchpad) | closed | Closed without a fix. Snapcraft prime crashed on invalid ELF files due to an uncaught ELFError. With zero comments and no PR, the report was abandoned or superseded by newer versions handling malformed binaries gracefully. | |
| #1660696 Snapcraft is testing file collisions on unbuilt parts | snapcraft (launchpad) | closed | Closed without a merged fix. Snapcraft incorrectly checked file collisions on unbuilt parts, causing file not found errors. The author verified a local workaround, but the report was closed without upstream resolution or discussion. | |
| #1795171 snapcraft fail to find built executable under prime $SNAP | snapcraft (launchpad) | closed | Closed without resolution or comments, likely abandoned. The issue reported a FileNotFoundError when Snapcraft failed to expand the $SNAP variable in the prime directory path during build. | |
| #1907721 Snapcraft broken on ARM64 | snapcraft (launchpad) | closed | Closed without comments. No fix or merge was applied. The ARM64 Multipass QEMU error and YAML !PrimeState deserialization bug were likely resolved by upstream Snapcraft updates or abandoned. | |
| #6206 snapcraft fails to unsquashfs some snaps | snapcraft | closed | Fixed by modifying the snap extraction utility to only extract required files, resolving unsquashfs failures on snaps containing character devices. The fix is included in Snapcraft 9. |