Skip to content

Commit 8e798ff

Browse files
authored
Merge pull request #908 from DeusData/fix/installps1-osarch
fix(install): detect arch via OSArchitecture, not PROCESSOR_ARCHITECTURE (arm64)
2 parents c424eff + e4d7d62 commit 8e798ff

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

install.ps1

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,20 @@ foreach ($arg in $args) {
3131
if ($arg -like "--dir=*") { $InstallDir = $arg.Substring(6) }
3232
}
3333

34-
# Detect architecture (ARM64 vs x64). PROCESSOR_ARCHITEW6432 is set to ARM64
35-
# when an x86/x64 process runs under emulation on ARM hardware, so check both to
36-
# resolve ARM64 even from an emulated shell; anything else falls back to amd64.
37-
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64" -or $env:PROCESSOR_ARCHITEW6432 -eq "ARM64") {
38-
$Arch = "arm64"
39-
} else {
40-
$Arch = "amd64"
34+
# Detect the OS architecture. RuntimeInformation.OSArchitecture reports the real
35+
# OS arch (Arm64) even from an x64 process running under emulation on ARM64 --
36+
# unlike $env:PROCESSOR_ARCHITECTURE, which reports the emulated "AMD64", and
37+
# PROCESSOR_ARCHITEW6432, which is unset for 64-bit emulated processes. Fall back
38+
# to the env vars only if the .NET API is somehow unavailable.
39+
try {
40+
$osArch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
41+
$Arch = if ($osArch -eq 'Arm64') { "arm64" } else { "amd64" }
42+
} catch {
43+
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64" -or $env:PROCESSOR_ARCHITEW6432 -eq "ARM64") {
44+
$Arch = "arm64"
45+
} else {
46+
$Arch = "amd64"
47+
}
4148
}
4249

4350
Write-Host "codebase-memory-mcp installer (Windows)"

0 commit comments

Comments
 (0)