fix(self-update): treat missing quarantine attribute as success#25
Merged
Conversation
`xattr -d com.apple.quarantine` exits non-zero when the attribute is absent. Because the binary is fetched over HTTP, macOS never stamps it with the quarantine flag, so removal of a non-existent attribute is the common case — yet it surfaced a misleading warning telling the user to re-run a command that would fail the same way. Extract `interpretXattrRemoval` and treat "No such xattr" (and ENOATTR / "attribute not found") as success, keeping the warning only for genuine failures (missing `xattr`, unexpected non-zero exit).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
wt self-updateprints a scary warning even on a fully successful update:The binary is downloaded over HTTP, so macOS never stamps it with
com.apple.quarantinein the first place.xattr -dthen exits non-zero withNo such xattr, which the code treated as a failure — surfacing a warning that tells the user to re-run a command that would fail the exact same way. The update itself succeeded; the warning is pure noise in the common case.Fix
Extract the exit-code/stderr interpretation into a pure
interpretXattrRemoval(exitCode, stderr)and treat a missing attribute (No such xattr,ENOATTR,attribute not found) as success. Genuine failures (missingxattr, unexpected non-zero exit) still surface the warning.Tests
Added unit tests for
interpretXattrRemovalcovering: exit 0, missing-attribute variants → ok, and genuine failures → err (with stderr message / exit-code fallback). Full suite: 519 pass.