Skip to content

Commit 3190662

Browse files
committed
Export BUNDLER_VERSION after installing Bundler
* Fixes #440
1 parent eb7f94f commit 3190662

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

bundler.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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,6 +146,14 @@ 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+
149157
return bundlerVersion
150158
}
151159

@@ -155,27 +163,19 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
155163
return false
156164
}
157165

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], envOptions)
171+
await exec.exec('bundle', ['config', '--local', 'path', bundleCachePath])
172172

173173
if (fs.existsSync(lockFile)) {
174-
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], envOptions)
174+
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'])
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'], envOptions)
178+
await exec.exec('bundle', ['lock'])
179179
}
180180

181181
await afterLockFile(lockFile, platform, engine, rubyVersion)

dist/index.js

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

0 commit comments

Comments
 (0)