Skip to content

fix: Rosetta environment is falsely detected as ARM architecture #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Utils/PlatformHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,20 @@ private static void DeterminePlatform() {
*/
try {
string arch;
using (Process uname = Process.Start(new ProcessStartInfo("uname", "-m") {
UseShellExecute = false,
RedirectStandardOutput = true
})) {
ProcessStartInfo processInfo;
if (Is(Platform.MacOS)) {
// on Rosetta environment, `uname -m` shows actual hardware architecture "arm64"
// and `arch` shows current hardware architecture `i386`
// We want to know current architecture so we call arch instead of uname.
processInfo = new ProcessStartInfo("arch") {
UseShellExecute = false, RedirectStandardOutput = true
};
} else {
processInfo = new ProcessStartInfo("uname", "-m") {
UseShellExecute = false, RedirectStandardOutput = true
};
}
using (Process uname = Process.Start(processInfo)) {
arch = uname.StandardOutput.ReadLine().Trim();
}

Expand Down