From 7a94c8d20e44f110d1d081284cd01f03230da633 Mon Sep 17 00:00:00 2001 From: Noah Gilson Date: Wed, 11 Sep 2024 09:35:49 -0700 Subject: [PATCH 1/3] fix emu --- .../src/Acquisition/WinMacGlobalInstaller.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts b/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts index c86984c3ac..d8ae3ae89b 100644 --- a/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts +++ b/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts @@ -208,8 +208,9 @@ This report should be made at https://github.com/dotnet/vscode-dotnet-runtime/is } else { - const command = CommandExecutor.makeCommand(`rm`, [`-rf`, `${path.join(path.dirname(this.getMacPath()), 'sdk', install.version)}`, `&&`, -`rm`, `-rf`, `${path.join(path.dirname(this.getMacPath()), 'sdk-manifests', install.version)}`], true); + const macPath = await this.getMacPath(); + const command = CommandExecutor.makeCommand(`rm`, [`-rf`, `${path.join(path.dirname(macPath), 'sdk', install.version)}`, `&&`, +`rm`, `-rf`, `${path.join(path.dirname(macPath), 'sdk-manifests', install.version)}`], true); const commandResult = await this.commandRunner.execute(command, {timeout : this.acquisitionContext.timeoutSeconds * 1000}); this.handleTimeout(commandResult); @@ -330,7 +331,8 @@ Permissions: ${JSON.stringify(await this.commandRunner.execute(CommandExecutor.m } else if(os.platform() === 'darwin') { - return this.getMacPath(macPathShouldExist); + const sdkPath = await this.getMacPath(macPathShouldExist); + return sdkPath; } const err = new DotnetUnexpectedInstallerOSError(new EventBasedError('DotnetUnexpectedInstallerOSError', @@ -352,10 +354,18 @@ If you were waiting for the install to succeed, please extend the timeout settin } } - private getMacPath(macPathShouldExist = true) : string + private async getMacPath(macPathShouldExist = true) : Promise { const standardHostPath = path.resolve(`/usr/local/share/dotnet/dotnet`); const arm64EmulationHostPath = path.resolve(`/usr/local/share/dotnet/x64/dotnet`); + + if((os.arch() === 'x64' || os.arch() === 'ia32') && (await this.commandRunner.execute(CommandExecutor.makeCommand(`uname`, [`-p`]), null, false)).stdout.includes('arm')) + { + // VS Code runs on an emulated version of node which will return x64 or use x86 emulation for ARM devices. + // os.arch() returns the architecture of the node binary, not the system architecture, so it will not report arm on an arm device. + return arm64EmulationHostPath; + } + if(!macPathShouldExist || fs.existsSync(standardHostPath) || !fs.existsSync(arm64EmulationHostPath)) { return standardHostPath; From 117b981757664c87f4af9930ce348cf4acf9c8f2 Mon Sep 17 00:00:00 2001 From: Noah Gilson Date: Wed, 11 Sep 2024 09:41:43 -0700 Subject: [PATCH 2/3] improve mac path check --- .../src/Acquisition/WinMacGlobalInstaller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts b/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts index d8ae3ae89b..c571078b9c 100644 --- a/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts +++ b/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts @@ -359,7 +359,8 @@ If you were waiting for the install to succeed, please extend the timeout settin const standardHostPath = path.resolve(`/usr/local/share/dotnet/dotnet`); const arm64EmulationHostPath = path.resolve(`/usr/local/share/dotnet/x64/dotnet`); - if((os.arch() === 'x64' || os.arch() === 'ia32') && (await this.commandRunner.execute(CommandExecutor.makeCommand(`uname`, [`-p`]), null, false)).stdout.includes('arm')) + const findTrueArchCommand = CommandExecutor.makeCommand(`uname`, [`-p`]); + if((os.arch() === 'x64' || os.arch() === 'ia32') && (await this.commandRunner.execute(findTrueArchCommand, null, false)).stdout.toLowerCase().includes('arm')) { // VS Code runs on an emulated version of node which will return x64 or use x86 emulation for ARM devices. // os.arch() returns the architecture of the node binary, not the system architecture, so it will not report arm on an arm device. From 42da6e8f91eec510e40b92ca4c9ebb399c6fcc48 Mon Sep 17 00:00:00 2001 From: Noah Gilson Date: Thu, 12 Sep 2024 16:47:24 -0700 Subject: [PATCH 3/3] Account for when SDK is not installed under emulation but node js is --- .../src/Acquisition/WinMacGlobalInstaller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts b/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts index c571078b9c..6752d7cc32 100644 --- a/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts +++ b/vscode-dotnet-runtime-library/src/Acquisition/WinMacGlobalInstaller.ts @@ -360,7 +360,7 @@ If you were waiting for the install to succeed, please extend the timeout settin const arm64EmulationHostPath = path.resolve(`/usr/local/share/dotnet/x64/dotnet`); const findTrueArchCommand = CommandExecutor.makeCommand(`uname`, [`-p`]); - if((os.arch() === 'x64' || os.arch() === 'ia32') && (await this.commandRunner.execute(findTrueArchCommand, null, false)).stdout.toLowerCase().includes('arm')) + if((os.arch() === 'x64' || os.arch() === 'ia32') && (await this.commandRunner.execute(findTrueArchCommand, null, false)).stdout.toLowerCase().includes('arm') && (fs.existsSync(arm64EmulationHostPath) || !macPathShouldExist)) { // VS Code runs on an emulated version of node which will return x64 or use x86 emulation for ARM devices. // os.arch() returns the architecture of the node binary, not the system architecture, so it will not report arm on an arm device.