11import { execSync } from "child_process" ;
2- import { isMac } from "../../services/utils" ;
2+ import { isMac , isWindows } from "../../services/utils" ;
3+ import { arch , cpus } from "os" ;
34
45function systemChecks ( ) {
56 return {
6- isCpuArchMismatch : isRunningUnderRosetta2 ( )
7+ isCpuArchMismatch : isCpuArchMismatch ( )
78 }
89}
910
@@ -13,8 +14,31 @@ function systemChecks() {
1314 * Uses the macOS sysctl.proc_translated to properly detect translation.
1415 * @returns true if running under Rosetta 2, false otherwise
1516 */
16- export const isRunningUnderRosetta2 = ( ) => {
17- return true ;
17+ export const isCpuArchMismatch = ( ) => {
18+ if ( isMac ) {
19+ try {
20+ // Use child_process to check sysctl.proc_translated
21+ // This is the proper way to detect Rosetta 2 translation
22+ const result = execSync ( "sysctl -n sysctl.proc_translated 2>/dev/null" , {
23+ encoding : "utf8" ,
24+ timeout : 1000
25+ } ) . trim ( ) ;
26+
27+ // 1 means the process is being translated by Rosetta 2
28+ // 0 means native execution
29+ // If the sysctl doesn't exist (on Intel Macs), this will return empty/error
30+ return result === "1" ;
31+ } catch ( error ) {
32+ // If sysctl fails or doesn't exist (Intel Macs), not running under Rosetta 2
33+ return false ;
34+ }
35+ } else if ( isWindows && arch ( ) === "x64" ) {
36+ return cpus ( ) . some ( cpu =>
37+ cpu . model . includes ( 'Microsoft SQ' ) ||
38+ cpu . model . includes ( 'Snapdragon' ) ) ;
39+ } else {
40+ return false ;
41+ }
1842} ;
1943
2044export default {
0 commit comments