Skip to content

fix: extract .tar.7z snap template archives correctly - #10003

Merged
mmaietta merged 1 commit into
masterfrom
fix/snap-template-tar7z-10002
Jul 11, 2026
Merged

fix: extract .tar.7z snap template archives correctly#10003
mmaietta merged 1 commit into
masterfrom
fix/snap-template-tar7z-10002

Conversation

@claude

@claude claude Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Requested by Samuel Attard · Slack thread

Before: building a snap with the default configuration (the useTemplateApp template path) on 26.15.0–26.15.6 succeeds without any error or warning, but the resulting snap dies at launch: desktop-init.sh: No such file or directory. The snap-template archive was packed into the snap as a single stray .tar file instead of its contents (desktop-init.sh, desktop-common.sh, desktop-gnome-specific.sh, usr/, …).

After: the template extracts correctly again, the desktop scripts land at the snap root with their executable modes intact, and built snaps launch. Upgrading users pick up the fix automatically — no manual cache clearing needed.

How

  • .tar.7z extraction: since the Go app-builder → TypeScript migration (feat(migration): fully replace Go binary app-builder-bin with TS implementation #9829, released in 26.15.0), snap template downloads go through extractArchive() in packages/app-builder-lib/src/util/electronGet.ts, which had no .tar.7z case. The template archives (e.g. snap-template-electron-4.0-2-amd64.tar.7z) matched the plain .7z branch, so only the outer 7z layer was removed. .tar.7z is now routed through the same decompress-then-untar path as .tar.xz/.txz: 7za strips the outer layer to the inner tar, then node-tar extracts it with strip: 1 (the inner tars are ./-prefixed), reproducing the layout the Go binary used to produce, including desktop-init.sh mode 755. The .tar.7z check runs before the plain .7z match.
  • Cache-busting rename: the toolset cache folder-name regex in downloadBuilderToolset() now strips the full .tar.7z extension (previously only .7z, leaving <name>.tar-<hash> dirs). This is deliberate: caches poisoned by the broken extraction pass the cache-complete check and would otherwise never be re-fetched after upgrading — the new dir name forces a clean re-extraction.
  • Regression tests: CI missed this because no test asserted template contents survive extraction. Added a focused extractArchive test against a crafted .tar.7z fixture (7z layer around a ./-prefixed tar with a mode-755 desktop-init.sh) asserting the extracted layout, file mode, and that no stray inner .tar remains — it reproduces the exact 26.15.x symptom when run against the unfixed code — plus an end-to-end downloadBuilderToolset test via the existing local-server pattern that also asserts the new cache dir name. A full template-path snap build with content assertions needs the RUN_SNAP_TESTS Docker containers (unsquashfs/Xvfb), so the fixture-based tests are the CI-runnable guard.

Fixes #10002

Credit to @aek-innonova for the excellent diagnosis — root cause, the poisoned-cache warning, and the proposed one-line routing fix, all verified — in the issue report.

cc @mmaietta


Generated by Claude Code

Since the app-builder Go-to-TS migration (26.15.0), extractArchive() had no
.tar.7z case: snap template archives fell through to the plain .7z branch,
so only the outer 7z layer was removed and default-config snap builds packed
the inner tar as a single file instead of the template contents
(desktop-init.sh etc). Builds succeeded silently; the snaps failed at launch.

- route .tar.7z through the decompress-then-untar path used for .tar.xz
  (7za strips the outer layer, node-tar extracts the inner tar with strip: 1)
- strip the full .tar.7z extension in the toolset cache dir name; the rename
  deliberately busts caches poisoned by the broken extraction, which would
  otherwise pass the cache-complete check forever after upgrading
- add a focused extractArchive regression test against a crafted .tar.7z
  fixture and an end-to-end downloadBuilderToolset test via a local server

Fixes #10002

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmEdZ2geUz4KSzYewFyB9M
@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f679d82

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
app-builder-lib Patch
dmg-builder Patch
electron-builder-squirrel-windows Patch
electron-builder Patch
electron-forge-maker-appimage Patch
electron-forge-maker-nsis-web Patch
electron-forge-maker-nsis Patch
electron-forge-maker-snap Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mmaietta
mmaietta merged commit 39df92f into master Jul 11, 2026
61 of 62 checks passed
@mmaietta
mmaietta deleted the fix/snap-template-tar7z-10002 branch July 11, 2026 04:09
liamcmitchell added a commit to liamcmitchell/electron-builder that referenced this pull request Jul 13, 2026
* origin/master:
  feat(updater): fix manifest sha512 hash-encoding sniffing, add opt-in Linux package-signature verification (electron-userland#9990)
  fix: don't empty locales dir when electronLanguages uses bare language codes (electron-userland#10007)
  fix: extract .tar.7z snap template archives correctly (electron-userland#10003)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snap template builds produce broken snaps since 26.15.x: template .tar.7z only 7z-extracted, desktop-init.sh missing

2 participants