@@ -13,6 +13,8 @@ const rubyInstallerVersions = require('./windows-versions').versions
1313
1414const drive = common . drive
1515
16+ const msys2BasePath = 'C:\\msys64'
17+
1618// needed for 2.0-2.3, and mswin, cert file used by Git for Windows
1719const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
1820
@@ -58,12 +60,12 @@ export async function install(platform, engine, version) {
5860
5961 const virtualEnv = common . getVirtualEnvironmentName ( )
6062
63+ if ( ! [ 'windows-2019' , 'windows-2016' ] . includes ( virtualEnv ) ) {
64+ await installMSY2Tools ( )
65+ }
66+
6167 if ( ( winMSYS2Type === 'ucrt64' ) || ! [ 'windows-2019' , 'windows-2016' ] . includes ( virtualEnv ) ) {
6268 await installGCCTools ( winMSYS2Type )
63-
64- if ( ! [ 'windows-2019' , 'windows-2016' ] . includes ( virtualEnv ) ) {
65- await installMSY2Tools ( )
66- }
6769 }
6870
6971 const ridk = `${ rubyPrefix } \\bin\\ridk.cmd`
@@ -85,7 +87,7 @@ async function installGCCTools(type) {
8587
8688 await common . measure ( `Extracting ${ type } build tools` , async ( ) =>
8789 // -aoa overwrite existing, -bd disable progress indicator
88- exec . exec ( '7z' , [ 'x' , downloadPath , '-aoa' , '-bd' , '-oC:\\msys64' ] , { silent : true } ) )
90+ exec . exec ( '7z' , [ 'x' , downloadPath , '-aoa' , '-bd' , `-o ${ msys2BasePath } ` ] , { silent : true } ) )
8991}
9092
9193// Actions windows-2022 image does not contain any MSYS2 build tools. Install tools for it.
@@ -97,9 +99,13 @@ async function installMSY2Tools() {
9799 return await tc . downloadTool ( url )
98100 } )
99101
102+ // need to remove all directories, since they may indicate old packages are installed,
103+ // otherwise, error of "error: duplicated database entry"
104+ fs . rmdirSync ( `${ msys2BasePath } \\var\\lib\\pacman\\local` , { recursive : true , force : true } )
105+
100106 await common . measure ( `Extracting msys2 build tools` , async ( ) =>
101107 // -aoa overwrite existing, -bd disable progress indicator
102- exec . exec ( '7z' , [ 'x' , downloadPath , '-aoa' , '-bd' , '-oC:\\msys64' ] , { silent : true } ) )
108+ exec . exec ( '7z' , [ 'x' , downloadPath , '-aoa' , '-bd' , `-o ${ msys2BasePath } ` ] , { silent : true } ) )
103109}
104110
105111async function downloadAndExtract ( engine , version , url , base , rubyPrefix ) {
0 commit comments