Repository navigation
fix(tempfile): avoid hdiutil deprecation warning on macOS 27 - #3610
Merged
dominikschulz merged 1 commit intoSep 22, 2026
Merged
Conversation
macOS 27 deprecated the hdiutil disk image interface that hdid(8) wraps. Attaching the ramdisk for a secure tempdir still works, but hdid now prints hdiutil: WARNING: 'hdiutil attach -nomount ...' is deprecated. Please use 'diskutil image attach --noMount ...' instead. to stderr on every call. tempfile passes that stderr straight through, so the warning surfaces in every gopass command that needs a secure tempdir, notably `gopass edit` and `gopass env`. Prefer `diskutil image attach --noMount --nobrowse` and fall back to hdid on releases without the `image` verb. The fallback's stderr is captured rather than passed through, so probing costs no output on older systems, and the outcome is memoized to avoid repeating the failed exec. The two commands format their output differently: hdid pads the device node with spaces and tabs, diskutil emits it bare. Parse with strings.Fields instead of cutting at the first space, which would have kept the trailing newline on diskutil's output. Also correct the ramdisk size comment: 32768 * 512 byte sectors is 16 MiB, not 32 MB. Signed-off-by: Parham Alvani <parham.alvani@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011xDya1SH2B8fmV7Mx8nDkd
dominikschulz
self-requested a review
September 15, 2026 20:04
Member
|
Thanks. Code looks reasonable, but I want to test this before merging. |
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.
Summary
On macOS 27, every gopass command that needs a secure tempdir prints a deprecation warning to stderr:
pkg/tempfilecreates its ramdisk withhdid -drivekey system-image=yes -nomount ram://32768.hdid(8)is a thin wrapper around the hdiutil disk image interface, which macOS 27 deprecated. The attach still succeeds, butmountsetscmd.Stderr = os.Stderr, so the warning goes straight to the user's terminal on everygopass edit,gopass env, and anything else that goes throughtempfile.New.Fix
Prefer
diskutil image attach --noMount --nobrowse ram://32768, and keephdidas a fallback for releases that predate theimageverb. The probe's stderr is captured rather than passed through, so users on older macOS see no output from an attempt that did not end up mattering, and the outcome is memoized so the failed exec happens at most once per process.The two commands format their output differently, so the device-node parsing had to change.
hdidpads the node with spaces and tabs (/dev/disk4 \t \t\n) whilediskutilemits it bare (/dev/disk4\n). The existingstrings.Split(out, " ")[0]happens to work forhdidbut would have kept the trailing newline ondiskutiloutput and produced an invalid device node;strings.Fieldshandles both.parseDevis covered by a new table test using the real output of both commands.Everything after the attach is unchanged —
newfs_hfsand thediskutil mount/unmountDisk/ejectcalls are not deprecated and work as before.Also corrects the ramdisk size comment: 32768 sectors of 512 bytes is 16 MiB, not the 32 MB the comment claimed.
newfs_hfsconfirms it —Initialized /dev/rdisk4 as a 16 MB case-insensitive HFS Plus volume.Testing
Verified on macOS 27.0 (build 26A428, arm64) with a small program calling
tempfile.Newand capturing stderr.Before, on
master:After, with this change — stderr is empty:
go test ./pkg/tempfile/...andgolangci-lint run pkg/tempfile/...both pass, and the full mount/write/unmount cycle was exercised end to end.I could not test the
hdidfallback path on a pre-27 machine — I do not have one to hand. The fallback is the previous code path, reached whenever thediskutilattempt returns an error, so a reviewer on an older release confirming thatgopass editstill works there would be worth having.🤖 Generated with Claude Code
https://claude.ai/code/session_011xDya1SH2B8fmV7Mx8nDkd