Skip to content

Commit 56f33e1

Browse files
hsbtclaude
andcommitted
Use the mswin master build from cache.ruby-lang.org
The mswin build of ruby-loco has not been updated since 2026-10-14. The builds at cache.ruby-lang.org are published daily under dated names for x64 and arm64, so the latest one is picked from index.json. Their OpenSSL looks for certificates in a directory that does not exist on runners, so SSL_CERT_FILE points at the bundle of Git for Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b67d5d9 commit 56f33e1

7 files changed

Lines changed: 112 additions & 19 deletions

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Native extensions are automatically compiled with AddressSanitizer when using `r
2929
`ruby-asan` and `asan-release` are currently only available on `ubuntu-24.04` and `ubuntu-26.04`.
3030

3131
Regarding Windows ruby master builds, `mingw` is a MSYS2/MinGW build, `head` & `ucrt` are MSYS2/UCRT64
32-
builds, and `mswin` is a MSVC/VS 2022 build.
32+
builds, and `mswin` is a MSVC build.
3333

3434
Preview and RC versions of Ruby might be available too on Ubuntu and macOS (not on Windows).
3535
However, it is recommended to test against `ruby-head` rather than previews,
@@ -62,7 +62,8 @@ only has builds of CRuby 3.2 and newer, as older CRuby versions do not compile o
6262

6363
The prebuilt releases are generated by [ruby-builder](https://github.com/ruby/ruby-builder)
6464
and on Windows by [RubyInstaller2](https://github.com/oneclick/rubyinstaller2).
65-
The `mingw`, `ucrt` and `mswin` builds are generated by [ruby-loco](https://github.com/MSP-Greg/ruby-loco).
65+
The `mingw` and `ucrt` builds are generated by [ruby-loco](https://github.com/MSP-Greg/ruby-loco).
66+
The `mswin` build is the daily master build published at [cache.ruby-lang.org](https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/).
6667
`ruby-head` is generated by [ruby-dev-builder](https://github.com/ruby/ruby-dev-builder),
6768
`jruby-head` is generated by [jruby-dev-builder](https://github.com/ruby/jruby-dev-builder),
6869
`truffleruby-head` and `truffleruby+graalvm-head` are generated by [truffleruby-dev-builder](https://github.com/ruby/truffleruby-dev-builder).

‎dist/index.js‎

Lines changed: 49 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎generate-test-matrix.rb‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ def unique_versions(versions, segment_count, *symbolic)
6060
matrix += (macos_arm64_runners + ubuntu_runners).product(truffleruby_versions)
6161

6262
# ruby-loco: head
63-
ruby_loco_versions = %w[mingw mswin ucrt]
63+
ruby_loco_versions = %w[mingw ucrt]
6464
matrix += windows_x64_runners.product(ruby_loco_versions)
6565

66+
# mswin: head
67+
matrix += windows_runners.product(%w[mswin])
68+
6669
# asan: latest release + head
6770
asan_versions = %w[asan-release asan]
6871
matrix += asan_runners.sort.last(1).product(asan_versions)

‎generate-windows-versions.rb‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
WINDOWS_VERSIONS_URLS_REGEXPS = [
1010
%r{\A#{Regexp.escape 'https://github.com/oneclick/rubyinstaller/releases/download'}/\w[\w.-]*/\w[\w.-]*\z},
1111
%r{\A#{Regexp.escape 'https://github.com/oneclick/rubyinstaller2/releases/download'}/\w[\w.-]*/\w[\w.-]*\z},
12-
%r{\A#{Regexp.escape 'https://github.com/MSP-Greg/ruby-loco/releases/download'}/\w[\w.-]*/\w[\w.-]*\z}
12+
%r{\A#{Regexp.escape 'https://github.com/MSP-Greg/ruby-loco/releases/download'}/\w[\w.-]*/\w[\w.-]*\z},
13+
%r{\A#{Regexp.escape 'https://cache.ruby-lang.org/pub/ruby/binaries/index.json'}\z}
1314
].freeze
1415

1516
WINDOWS_TOOLCHAIN_VERSIONS_URLS_REGEXPS = [
@@ -66,8 +67,10 @@ def validate(versions, allowed_urls_regexps)
6667
versions['mingw'] = {
6768
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z'
6869
}
70+
# The latest master build is picked from the index at runtime, see getLatestMswinURL in windows.js
6971
versions['mswin'] = {
70-
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z'
72+
'arm64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/index.json',
73+
'x64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/index.json'
7174
}
7275
versions['ucrt'] = {
7376
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-ucrt.7z'
@@ -92,7 +95,7 @@ def validate(versions, allowed_urls_regexps)
9295
when 'mingw'
9396
"#{arch}-mingw32"
9497
when 'mswin'
95-
"#{arch}-mswin64"
98+
"#{raw_arch}-mswin64"
9699
else
97100
if version >= Gem::Version.new('3.1.0.dev')
98101
"#{arch}-mingw-ucrt"

‎windows-toolchain-versions.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@
346346
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/download/v20261024.010459/msys2-mingw64.7z"
347347
},
348348
"mswin": {
349+
"arm64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-arm64-windows.7z",
349350
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
350351
},
351352
"ucrt": {

‎windows-versions.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@
346346
"x64": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z"
347347
},
348348
"mswin": {
349-
"x64": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z"
349+
"arm64": "https://cache.ruby-lang.org/pub/ruby/binaries/index.json",
350+
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/index.json"
350351
},
351352
"ucrt": {
352353
"x64": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-ucrt.7z"

‎windows.js‎

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ export function getAvailableVersions(_platform, engine) {
2020
}
2121

2222
export async function install(platform, engine, version) {
23-
const url = rubyInstallerVersions[version][os.arch()]
23+
let url = rubyInstallerVersions[version][os.arch()]
24+
if (version === 'mswin') {
25+
url = await getLatestMswinURL(url)
26+
}
2427

25-
if (!url.endsWith('.7z')) {
26-
throw new Error(`URL should end in .7z: ${url}`)
28+
const ext = path.posix.extname(url)
29+
if (ext !== '.7z' && ext !== '.zip') {
30+
throw new Error(`URL should end in .7z or .zip: ${url}`)
2731
}
28-
const base = path.posix.basename(url, '.7z')
32+
const base = path.posix.basename(url, ext)
2933

3034
let rubyPrefix, inToolCache
3135
if (common.shouldUseToolCache(engine, version)) {
@@ -43,6 +47,10 @@ export async function install(platform, engine, version) {
4347
await downloadAndExtract(engine, version, url, base, rubyPrefix);
4448
}
4549

50+
if (version === 'mswin') {
51+
exportEnv({ SSL_CERT_FILE: findGitCertFile() })
52+
}
53+
4654
const paths = [`${rubyPrefix}\\bin`]
4755
const windowsToolchain = core.getInput('windows-toolchain')
4856
if (windowsToolchain === 'none') {
@@ -77,6 +85,33 @@ export async function install(platform, engine, version) {
7785
return rubyPrefix
7886
}
7987

88+
// mswin master builds are published daily under dated names, so pick the latest one from the index
89+
async function getLatestMswinURL(indexURL) {
90+
// Retry like tc.downloadTool does for the archive, so a transient failure of the index does not fail the job
91+
let response
92+
for (let attempt = 1; attempt <= 3; attempt++) {
93+
try {
94+
response = await fetch(indexURL, { signal: AbortSignal.timeout(30000) })
95+
if (response.ok) break
96+
} catch (error) {
97+
if (attempt === 3) throw error
98+
}
99+
if (attempt < 3) await new Promise(resolve => setTimeout(resolve, 5000))
100+
}
101+
if (!response.ok) {
102+
throw new Error(`Failed to fetch ${indexURL}: ${response.status} ${response.statusText}`)
103+
}
104+
105+
const platform = `${os.arch()}-mswin64_140`
106+
const builds = (await response.json()).builds.filter(build => build.channel === 'dev' && build.platform === platform)
107+
if (builds.length === 0) {
108+
throw new Error(`No mswin build for ${platform} in ${indexURL}`)
109+
}
110+
111+
// The index is sorted by name, and the date in the name can differ from the date it was published
112+
return builds.reduce((latest, build) => build.published_at > latest.published_at ? build : latest).url
113+
}
114+
80115
async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
81116
const downloadPath = await common.measure('Downloading Ruby', async () => {
82117
console.log(url)
@@ -148,15 +183,22 @@ async function installMSYS2(url, rubyPrefix = process.env.RUNNER_TEMP) {
148183
return [`${msys2Path}\\${msys2Type}\\bin`, `${msys2Path}\\usr\\bin`]
149184
}
150185

151-
async function installMSYS1(url) {
186+
// DevKit and mswin Rubies have no usable CA certificates on runners, so they use the bundle of Git for Windows
187+
function findGitCertFile() {
152188
const certFile = [
153189
'C:\\Program Files\\Git\\ucrt64\\etc\\ssl\\cert.pem',
154190
'C:\\Program Files\\Git\\mingw64\\etc\\ssl\\cert.pem',
155191
'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem',
192+
'C:\\Program Files\\Git\\clangarm64\\etc\\ssl\\cert.pem',
156193
].find(file => fs.existsSync(file))
157194
if (certFile === undefined) {
158195
throw new Error("Cannot find Git's cert file")
159196
}
197+
return certFile
198+
}
199+
200+
async function installMSYS1(url) {
201+
const certFile = findGitCertFile()
160202

161203
const downloadPath = await common.measure('Downloading msys1 build tools', async () => {
162204
console.log(url)

0 commit comments

Comments
 (0)