From 4fbcf63963d544d44b54ee1f76f4748ec0ae70a4 Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sun, 21 Nov 2021 13:15:14 -0600 Subject: [PATCH] Install MSYS2 tools before gcc tools, clear pacman database folder --- windows.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/windows.js b/windows.js index f078836..a0deb71 100644 --- a/windows.js +++ b/windows.js @@ -13,6 +13,8 @@ const rubyInstallerVersions = require('./windows-versions').versions const drive = common.drive +const msys2BasePath = 'C:\\msys64' + // needed for 2.0-2.3, and mswin, cert file used by Git for Windows const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem' @@ -58,12 +60,12 @@ export async function install(platform, engine, version) { const virtualEnv = common.getVirtualEnvironmentName() + if (!['windows-2019', 'windows-2016'].includes(virtualEnv)) { + await installMSY2Tools() + } + if (( winMSYS2Type === 'ucrt64') || !['windows-2019', 'windows-2016'].includes(virtualEnv)) { await installGCCTools(winMSYS2Type) - - if (!['windows-2019', 'windows-2016'].includes(virtualEnv)) { - await installMSY2Tools() - } } const ridk = `${rubyPrefix}\\bin\\ridk.cmd` @@ -85,7 +87,7 @@ async function installGCCTools(type) { await common.measure(`Extracting ${type} build tools`, async () => // -aoa overwrite existing, -bd disable progress indicator - exec.exec('7z', ['x', downloadPath, '-aoa', '-bd', '-oC:\\msys64'], { silent: true })) + exec.exec('7z', ['x', downloadPath, '-aoa', '-bd', `-o${msys2BasePath}`], { silent: true })) } // Actions windows-2022 image does not contain any MSYS2 build tools. Install tools for it. @@ -97,9 +99,13 @@ async function installMSY2Tools() { return await tc.downloadTool(url) }) + // need to remove all directories, since they may indicate old packages are installed, + // otherwise, error of "error: duplicated database entry" + fs.rmdirSync(`${msys2BasePath}\\var\\lib\\pacman\\local`, { recursive: true, force: true }) + await common.measure(`Extracting msys2 build tools`, async () => // -aoa overwrite existing, -bd disable progress indicator - exec.exec('7z', ['x', downloadPath, '-aoa', '-bd', '-oC:\\msys64'], { silent: true })) + exec.exec('7z', ['x', downloadPath, '-aoa', '-bd', `-o${msys2BasePath}`], { silent: true })) } async function downloadAndExtract(engine, version, url, base, rubyPrefix) {