Skip to content

Commit 03b78bd

Browse files
piotrmuracheregon
authored andcommitted
Fix automatic bundler installation on JRuby 9.2
1 parent 5fe1a66 commit 03b78bd

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

bundler.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,14 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
120120
}
121121
}
122122

123-
// Use Bundler 2.3 when we use Ruby 2.3.2-2.5
123+
const targetRubyVersion = common.targetRubyVersion(engine, rubyVersion)
124+
// Use Bundler 2.3 when we use Ruby 2.3.2 - 2.5
124125
// Use Bundler 2.4 when we use Ruby 2.6-2.7
125126
if (bundlerVersion == '2') {
126-
if (engine === 'ruby' && floatVersion <= 2.5) {
127-
console.log('Ruby 2.3.2-2.5 only works with Bundler 2.3')
127+
if (targetRubyVersion <= 2.5) { // < 2.3.2 already handled above
128+
console.log('Ruby 2.3.2 - 2.5 only works with Bundler 2.3')
128129
bundlerVersion = '2.3'
129-
} else if (engine === 'ruby' && floatVersion <= 2.7) {
130+
} else if (targetRubyVersion <= 2.7) {
130131
console.log('Ruby 2.6-2.7 only works with Bundler 2.4')
131132
bundlerVersion = '2.4'
132133
}

common.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@ export function isBundler2dot2Default(engine, rubyVersion) {
9595
}
9696
}
9797

98+
export function targetRubyVersion(engine, rubyVersion) {
99+
const version = floatVersion(rubyVersion)
100+
if (engine === 'ruby') {
101+
return version
102+
} else if (engine === 'jruby') {
103+
if (version === 9.1) {
104+
return 2.3
105+
} else if (version === 9.2) {
106+
return 2.5
107+
} else if (version === 9.3) {
108+
return 2.6
109+
}
110+
}
111+
112+
return 9.9 // unknown, assume recent
113+
}
114+
98115
export function floatVersion(rubyVersion) {
99116
const match = rubyVersion.match(/^\d+\.\d+/)
100117
if (match) {

dist/index.js

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

0 commit comments

Comments
 (0)