Skip to content

Commit fb7550a

Browse files
hsbtclaude
andcommitted
Use the stable URL of the mswin master build
cache.ruby-lang.org publishes the newest dev build as ruby-head-<platform>.zip, so there is no need to look it up in index.json at runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c85f40c commit fb7550a

4 files changed

Lines changed: 8 additions & 69 deletions

File tree

‎dist/index.js‎

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

‎generate-windows-versions.rb‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
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},
1212
%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}
13+
%r{\A#{Regexp.escape 'https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev'}/\w[\w.-]*\z}
1414
].freeze
1515

1616
WINDOWS_TOOLCHAIN_VERSIONS_URLS_REGEXPS = [
@@ -67,10 +67,9 @@ def validate(versions, allowed_urls_regexps)
6767
versions['mingw'] = {
6868
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z'
6969
}
70-
# The latest master build is picked from the index at runtime, see getLatestMswinURL in windows.js
7170
versions['mswin'] = {
72-
'arm64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/index.json',
73-
'x64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/index.json'
71+
'arm64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev/ruby-head-arm64-mswin64_140.zip',
72+
'x64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev/ruby-head-x64-mswin64_140.zip'
7473
}
7574
versions['ucrt'] = {
7675
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-ucrt.7z'

‎windows-versions.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@
346346
"x64": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z"
347347
},
348348
"mswin": {
349-
"arm64": "https://cache.ruby-lang.org/pub/ruby/binaries/index.json",
350-
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/index.json"
349+
"arm64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev/ruby-head-arm64-mswin64_140.zip",
350+
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev/ruby-head-x64-mswin64_140.zip"
351351
},
352352
"ucrt": {
353353
"x64": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-ucrt.7z"

‎windows.js‎

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ export function getAvailableVersions(_platform, engine) {
2020
}
2121

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

2825
const ext = path.posix.extname(url)
2926
if (ext !== '.7z' && ext !== '.zip') {
@@ -85,33 +82,6 @@ export async function install(platform, engine, version) {
8582
return rubyPrefix
8683
}
8784

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-
11585
async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
11686
const downloadPath = await common.measure('Downloading Ruby', async () => {
11787
console.log(url)

0 commit comments

Comments
 (0)