File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -261,11 +261,22 @@ get_architecture() {
261
261
# get the real answer, but that's hard to ensure, so instead we use
262
262
# `sysctl` (which doesn't lie) to check for the actual architecture.
263
263
if [ " $_cputype " = i386 ]; then
264
- if sysctl hw.optional.x86_64 | grep -q ' : 1' ; then
264
+ # Handling i386 compatibility mode in older macOS versions (<10.15)
265
+ # running on x86_64-based Macs.
266
+ # Starting from 10.15, macOS explicitly bans all i386 binaries from running.
267
+ # See: <https://support.apple.com/en-us/HT208436>
268
+
269
+ # Avoid `sysctl: unknown oid` stderr output and/or non-zero exit code.
270
+ if sysctl hw.optional.x86_64 2> /dev/null || true | grep -q ' : 1' ; then
265
271
_cputype=x86_64
266
272
fi
267
273
elif [ " $_cputype " = x86_64 ]; then
268
- if sysctl hw.optional.arm64 | grep -q ' : 1' ; then
274
+ # Handling x86-64 compatibility mode (a.k.a. Rosetta 2)
275
+ # in newer macOS versions (>=11) running on arm64-based Macs.
276
+ # Rosetta 2 is built exclusively for x86-64 and cannot run i386 binaries.
277
+
278
+ # Avoid `sysctl: unknown oid` stderr output and/or non-zero exit code.
279
+ if sysctl hw.optional.arm64 2> /dev/null || true | grep -q ' : 1' ; then
269
280
_cputype=arm64
270
281
fi
271
282
fi
You can’t perform that action at this time.
0 commit comments