@@ -126,7 +126,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
126126 const targetRubyVersion = common . targetRubyVersion ( engine , rubyVersion )
127127 // Use Bundler 2.3 when we use Ruby 2.3.2 - 2.5
128128 // Use Bundler 2.4 when we use Ruby 2.6-2.7
129- if ( bundlerVersion === '2' ) {
129+ if ( bundlerVersion == '2' ) {
130130 if ( targetRubyVersion <= 2.5 ) { // < 2.3.2 already handled above
131131 console . log ( 'Ruby 2.3.2 - 2.5 only works with Bundler 2.3' )
132132 bundlerVersion = '2.3'
@@ -146,14 +146,6 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
146146
147147 await exec . exec ( gem , [ 'install' , 'bundler' , ...force , '-v' , bundlerVersionConstraint ] )
148148
149- if ( bundlerVersion . startsWith ( '1' ) && common . isBundler2Default ( engine , rubyVersion ) ) {
150- // If Bundler 1 is specified on Rubies which ship with Bundler 2,
151- // we need to specify which Bundler version to use explicitly until the lockfile exists.
152- // We actually set it globally for the case of bundler-cache: false with manual bundler install later.
153- console . log ( `Setting BUNDLER_VERSION=${ bundlerVersion } to ensure Bundler 1 is used` )
154- core . exportVariable ( 'BUNDLER_VERSION' , bundlerVersion )
155- }
156-
157149 return bundlerVersion
158150}
159151
@@ -163,19 +155,27 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
163155 return false
164156 }
165157
158+ let envOptions = { }
159+ if ( bundlerVersion . startsWith ( '1' ) && common . isBundler2Default ( engine , rubyVersion ) ) {
160+ // If Bundler 1 is specified on Rubies which ship with Bundler 2,
161+ // we need to specify which Bundler version to use explicitly until the lockfile exists.
162+ console . log ( `Setting BUNDLER_VERSION=${ bundlerVersion } for "bundle config|lock" commands below to ensure Bundler 1 is used` )
163+ envOptions = { env : { ...process . env , BUNDLER_VERSION : bundlerVersion } }
164+ }
165+
166166 // config
167167 const cachePath = 'vendor/bundle'
168168 // An absolute path, so it is reliably under $PWD/vendor/bundle, and not relative to the gemfile's directory
169169 const bundleCachePath = path . join ( process . cwd ( ) , cachePath )
170170
171- await exec . exec ( 'bundle' , [ 'config' , '--local' , 'path' , bundleCachePath ] )
171+ await exec . exec ( 'bundle' , [ 'config' , '--local' , 'path' , bundleCachePath ] , envOptions )
172172
173173 if ( fs . existsSync ( lockFile ) ) {
174- await exec . exec ( 'bundle' , [ 'config' , '--local' , 'deployment' , 'true' ] )
174+ await exec . exec ( 'bundle' , [ 'config' , '--local' , 'deployment' , 'true' ] , envOptions )
175175 } else {
176176 // Generate the lockfile so we can use it to compute the cache key.
177177 // This will also automatically pick up the latest gem versions compatible with the Gemfile.
178- await exec . exec ( 'bundle' , [ 'lock' ] )
178+ await exec . exec ( 'bundle' , [ 'lock' ] , envOptions )
179179 }
180180
181181 await afterLockFile ( lockFile , platform , engine , rubyVersion )
0 commit comments