Skip to content

fix: self-update extracts the binary, not its directory - #64

Merged
animeshchaudhri merged 1 commit into
rust-man-org:masterfrom
barnumbirr:fix/self-update-extracts-regular-files
Oct 21, 2026
Merged

animeshchaudhri merged 1 commit into
rust-man-org:masterfrom
barnumbirr:fix/self-update-extracts-regular-files

Conversation

@barnumbirr

Copy link
Copy Markdown
Contributor

In-app updates on Linux fail with "extracted binary is too small" whenever the update is the standard Linux tarball, which since v0.3.12-dev.47 packs the binary inside a directory. v0.3.15-dev.51 ships only that tarball, so every Linux update to it fails.

The Linux release tarball is packed with tar czf rustman-linux-<arch>.tar.gz -C dist rustman, so its first member is the directory entry rustman/. extract_binary takes the first entry whose file name is rustman, and Path::new("rustman/").file_name() is rustman too, so it writes the directory out as an empty file and verify_binary rejects it. While the -nokit tarball existed this was hidden: its directory is rustman-nokit/, and the asset picker chose it first (the mix-up fixed for #62).

extract_binary now takes regular files only (entry.header().entry_type().is_file()).

Testing

  • The published rustman-linux-x86_64.tar.gz of v0.3.15-dev.51 through extract_binary and verify_binary: on master Err("extracted binary is too small") with 0 bytes written; with this change Ok, 23,450,952 bytes, the size tar tv lists for rustman/rustman.
  • New tests extracts_the_binary_from_the_linux_tarball_layout and extracts_the_binary_from_the_macos_tarball_layout build those two layouts with tar::Builder (a directory entry first, as GNU tar writes it, and a single file at the root) and extract them. Without the check the Linux one fails with an empty file and the macOS one passes, as on master.
  • cargo test --bins: 141 passed and 3 ignored; with --no-default-features 131 and 3. cargo check --all-targets --target x86_64-pc-windows-gnu passes with master's one warning. rustfmt and clippy are clean on the change.

Not tested on macOS or Windows. The macOS tarball holds the binary at its root, the layout the second test covers; Windows goes through the zip path, which this change does not touch.

The Linux release tarball is packed with `tar czf ... -C dist rustman`,
so its first member is the directory entry `rustman/`. extract_binary
took the first entry whose file name is `rustman`, and a directory's
path `rustman/` has that file name too, so it wrote out the directory as
an empty file and verify_binary failed with "extracted binary is too
small". Every in-app update on Linux failed this way; while the -nokit
tarball existed it was hidden, because its directory is
`rustman-nokit/` and builds picked it first.

extract_binary now takes regular files only. Tests build the Linux and
macOS tarball layouts and extract them.
@animeshchaudhri
animeshchaudhri merged commit 0933afb into rust-man-org:master Oct 21, 2026
2 checks passed
@barnumbirr
barnumbirr deleted the fix/self-update-extracts-regular-files branch October 24, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants