@@ -63,12 +63,12 @@ export async function setupRuby(options = {}) {
6363 if ( inputs [ 'bundler' ] !== 'none' ) {
6464 const [ gemfile , lockFile ] = detectGemfiles ( )
6565
66- await common . measure ( 'Installing Bundler' , async ( ) =>
66+ const bundlerVersion = await common . measure ( 'Installing Bundler' , async ( ) =>
6767 installBundler ( inputs [ 'bundler' ] , lockFile , platform , rubyPrefix , engine , version ) )
6868
6969 if ( inputs [ 'bundler-cache' ] === 'true' ) {
7070 await common . measure ( 'bundle install' , async ( ) =>
71- bundleInstall ( gemfile , lockFile , platform , engine , version ) )
71+ bundleInstall ( gemfile , lockFile , platform , engine , version , bundlerVersion ) )
7272 }
7373 }
7474
@@ -231,31 +231,32 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
231231 await exec . exec ( gem , [ 'install' , 'bundler' , '-v' , `~> ${ bundlerVersion } ` , '--no-document' ] )
232232 }
233233
234- core . exportVariable ( 'BUNDLER_VERSION' , bundlerVersion )
234+ return bundlerVersion
235235}
236236
237- async function bundleInstall ( gemfile , lockFile , platform , engine , version ) {
237+ async function bundleInstall ( gemfile , lockFile , platform , engine , rubyVersion , bundlerVersion ) {
238238 if ( gemfile === null ) {
239239 console . log ( 'Could not determine gemfile path, skipping "bundle install" and caching' )
240240 return false
241241 }
242242
243243 // config
244244 const path = 'vendor/bundle'
245+ const optionsWithBundlerVersion = { options : { env : { ...process . env , BUNDLER_VERSION : bundlerVersion } } }
245246
246- await exec . exec ( 'bundle' , [ 'config' , '--local' , 'path' , path ] )
247+ await exec . exec ( 'bundle' , [ 'config' , '--local' , 'path' , path ] , optionsWithBundlerVersion )
247248
248249 if ( fs . existsSync ( lockFile ) ) {
249- await exec . exec ( 'bundle' , [ 'config' , '--local' , 'deployment' , 'true' ] )
250+ await exec . exec ( 'bundle' , [ 'config' , '--local' , 'deployment' , 'true' ] , optionsWithBundlerVersion )
250251 } else {
251252 // Generate the lockfile so we can use it to compute the cache key.
252253 // This will also automatically pick up the latest gem versions compatible with the Gemfile.
253- await exec . exec ( 'bundle' , [ 'lock' ] )
254+ await exec . exec ( 'bundle' , [ 'lock' ] , optionsWithBundlerVersion )
254255 }
255256
256257 // cache key
257258 const paths = [ path ]
258- const baseKey = await computeBaseKey ( platform , engine , version , lockFile )
259+ const baseKey = await computeBaseKey ( platform , engine , rubyVersion , lockFile )
259260 const key = `${ baseKey } -${ await common . hashFile ( lockFile ) } `
260261 // If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below
261262 const restoreKeys = [ `${ baseKey } -` ]
0 commit comments