@@ -67,17 +67,15 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
6767 }
6868 }
6969
70- const floatVersion = common . floatVersion ( rubyVersion )
71-
7270 if ( bundlerVersion === 'default' ) {
73- if ( common . isBundler2dot2Default ( engine , rubyVersion ) ) {
71+ if ( common . isBundler2dot2PlusDefault ( engine , rubyVersion ) ) {
7472 if ( common . windows && engine === 'ruby' && ( common . isStableVersion ( engine , rubyVersion ) || rubyVersion === 'head' ) ) {
7573 // https://github.com/ruby/setup-ruby/issues/371
7674 console . log ( `Installing latest Bundler for ${ engine } -${ rubyVersion } on Windows because bin/bundle does not work in bash otherwise` )
7775 bundlerVersion = 'latest'
7876 } else {
79- console . log ( `Using Bundler 2 shipped with ${ engine } -${ rubyVersion } ` )
80- return '2 '
77+ console . log ( `Using Bundler shipped with ${ engine } -${ rubyVersion } ` )
78+ return 'default '
8179 }
8280 } else if ( common . hasBundlerDefaultGem ( engine , rubyVersion ) ) {
8381 // Those Rubies have a old Bundler default gem < 2.2 which does not work well for `gem 'foo', github: 'foo/foo'`:
@@ -91,7 +89,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
9189 }
9290
9391 if ( bundlerVersion === 'latest' ) {
94- bundlerVersion = '2 '
92+ bundlerVersion = '4 '
9593 }
9694
9795 if ( isValidBundlerVersion ( bundlerVersion ) ) {
@@ -100,30 +98,31 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
10098 throw new Error ( `Cannot parse bundler input: ${ bundlerVersion } ` )
10199 }
102100
103- // Use Bundler 1 when we know Bundler 2 does not work
104- if ( bundlerVersion . startsWith ( '2' ) ) {
105- if ( engine === 'ruby' && floatVersion <= 2.2 ) {
106- console . log ( 'Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2' )
101+ const targetRubyVersion = common . targetRubyVersion ( engine , rubyVersion )
102+
103+ // Use Bundler 1 when we know Bundler 2+ does not work
104+ // Use Bundler 2.3 when we use Ruby 2.3.2 - 2.5
105+ // Use Bundler 2.4 when we use Ruby 2.6-2.7
106+ // Use Bundler 2.x when we use Ruby 3.0-3.1
107+ if ( common . floatVersion ( bundlerVersion ) >= 2 ) {
108+ if ( engine === 'ruby' && targetRubyVersion <= 2.2 ) {
109+ console . log ( `Bundler 2+ requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2` )
107110 bundlerVersion = '1'
108111 } else if ( engine === 'ruby' && / ^ 2 \. 3 \. [ 0 1 ] / . test ( rubyVersion ) ) {
109112 console . log ( 'Ruby 2.3.0 and 2.3.1 have shipped with an old rubygems that only works with Bundler 1' )
110113 bundlerVersion = '1'
111114 } else if ( engine === 'jruby' && rubyVersion . startsWith ( '9.1' ) ) { // JRuby 9.1 targets Ruby 2.3, treat it the same
112- console . log ( 'JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1' )
115+ console . log ( 'JRuby 9.1 has a bug with Bundler 2+ (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1' )
113116 bundlerVersion = '1'
114- }
115- }
116-
117- const targetRubyVersion = common . targetRubyVersion ( engine , rubyVersion )
118- // Use Bundler 2.3 when we use Ruby 2.3.2 - 2.5
119- // Use Bundler 2.4 when we use Ruby 2.6-2.7
120- if ( bundlerVersion == '2' ) {
121- if ( targetRubyVersion <= 2.5 ) { // < 2.3.2 already handled above
117+ } else if ( targetRubyVersion <= 2.5 ) { // < 2.3.2 already handled above
122118 console . log ( 'Ruby 2.3.2 - 2.5 only works with Bundler 2.3' )
123119 bundlerVersion = '2.3'
124120 } else if ( targetRubyVersion <= 2.7 ) {
125121 console . log ( 'Ruby 2.6-2.7 only works with Bundler 2.4' )
126122 bundlerVersion = '2.4'
123+ } else if ( targetRubyVersion <= 3.1 && common . floatVersion ( bundlerVersion ) > 2 ) {
124+ console . log ( 'Ruby 3.0-3.1 only works with Bundler 2 (Bundler 4 requires Ruby 3.2+)' )
125+ bundlerVersion = '2'
127126 }
128127 }
129128
@@ -144,8 +143,8 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
144143 }
145144
146145 let envOptions = { }
147- if ( bundlerVersion . startsWith ( '1' ) && common . isBundler2Default ( engine , rubyVersion ) ) {
148- // If Bundler 1 is specified on Rubies which ship with Bundler 2,
146+ if ( bundlerVersion . startsWith ( '1' ) && common . isBundler2PlusDefault ( engine , rubyVersion ) ) {
147+ // If Bundler 1 is specified on Rubies which ship with Bundler 2+ ,
149148 // we need to specify which Bundler version to use explicitly until the lockfile exists.
150149 console . log ( `Setting BUNDLER_VERSION=${ bundlerVersion } for "bundle config|lock" commands below to ensure Bundler 1 is used` )
151150 envOptions = { env : { ...process . env , BUNDLER_VERSION : bundlerVersion } }
@@ -156,10 +155,10 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
156155 // An absolute path, so it is reliably under $PWD/vendor/bundle, and not relative to the gemfile's directory
157156 const bundleCachePath = path . join ( process . cwd ( ) , cachePath )
158157
159- await exec . exec ( 'bundle' , [ 'config' , '--local' , 'path' , bundleCachePath ] , envOptions )
158+ await exec . exec ( 'bundle' , [ 'config' , 'set' , ' --local', 'path' , bundleCachePath ] , envOptions )
160159
161160 if ( fs . existsSync ( lockFile ) ) {
162- await exec . exec ( 'bundle' , [ 'config' , '--local' , 'deployment' , 'true' ] , envOptions )
161+ await exec . exec ( 'bundle' , [ 'config' , 'set' , ' --local', 'deployment' , 'true' ] , envOptions )
163162 } else {
164163 // Generate the lockfile so we can use it to compute the cache key.
165164 // This will also automatically pick up the latest gem versions compatible with the Gemfile.
0 commit comments