@@ -68,11 +68,19 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
6868 }
6969 }
7070
71+ const floatVersion = common . floatVersion ( rubyVersion )
72+
7173 if ( bundlerVersion === 'default' ) {
72- if ( common . isBundler2Default ( engine , rubyVersion ) ) {
74+ if ( engine === 'ruby' && floatVersion < 3.0 && common . hasBundlerDefaultGem ( engine , rubyVersion ) ) {
75+ // Ruby 2.6 and 2.7 have a old Bundler default gem which does not work well for `gem 'foo', github: 'foo/foo'`:
76+ // https://github.com/ruby/setup-ruby/issues/358#issuecomment-1195899304
77+ // Also, Ruby 2.6 would get Bundler 1 yet Ruby 2.3 - 2.5 get latest Bundler 2 which might be unexpected.
78+ console . log ( `Using latest Bundler for ${ engine } -${ rubyVersion } because the default Bundler gem is too old for that Ruby version` )
79+ bundlerVersion = 'latest'
80+ } else if ( common . isBundler2Default ( engine , rubyVersion ) ) {
7381 console . log ( `Using Bundler 2 shipped with ${ engine } -${ rubyVersion } ` )
7482 return '2'
75- } else if ( common . isBundler1Default ( engine , rubyVersion ) ) {
83+ } else if ( common . isBundler1Default ( engine , rubyVersion ) && engine !== 'ruby' ) {
7684 console . log ( `Using Bundler 1 shipped with ${ engine } -${ rubyVersion } ` )
7785 return '1'
7886 } else {
@@ -90,8 +98,6 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
9098 throw new Error ( `Cannot parse bundler input: ${ bundlerVersion } ` )
9199 }
92100
93- const floatVersion = common . floatVersion ( rubyVersion )
94-
95101 // Use Bundler 1 when we know Bundler 2 does not work
96102 if ( bundlerVersion . startsWith ( '2' ) ) {
97103 if ( engine === 'ruby' && floatVersion <= 2.2 ) {
0 commit comments