Skip to content

Commit

Permalink
Revert "Export BUNDLER_VERSION after installing Bundler"
Browse files Browse the repository at this point in the history
* This reverts commit 3190662.
* It causes other issues such as #444
  due to creating additional global state.
* The use-case it solves is too niche to risk such issues,
  using `bundler-cache: true` avoids the problem.
* See #444 (comment)
  • Loading branch information
eregon committed Jan 10, 2023
1 parent 3190662 commit 93287a1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 12 additions & 12 deletions bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
const targetRubyVersion = common.targetRubyVersion(engine, rubyVersion)
// Use Bundler 2.3 when we use Ruby 2.3.2 - 2.5
// Use Bundler 2.4 when we use Ruby 2.6-2.7
if (bundlerVersion === '2') {
if (bundlerVersion == '2') {
if (targetRubyVersion <= 2.5) { // < 2.3.2 already handled above
console.log('Ruby 2.3.2 - 2.5 only works with Bundler 2.3')
bundlerVersion = '2.3'
Expand All @@ -146,14 +146,6 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock

await exec.exec(gem, ['install', 'bundler', ...force, '-v', bundlerVersionConstraint])

if (bundlerVersion.startsWith('1') && common.isBundler2Default(engine, rubyVersion)) {
// If Bundler 1 is specified on Rubies which ship with Bundler 2,
// we need to specify which Bundler version to use explicitly until the lockfile exists.
// We actually set it globally for the case of bundler-cache: false with manual bundler install later.
console.log(`Setting BUNDLER_VERSION=${bundlerVersion} to ensure Bundler 1 is used`)
core.exportVariable('BUNDLER_VERSION', bundlerVersion)
}

return bundlerVersion
}

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

let envOptions = {}
if (bundlerVersion.startsWith('1') && common.isBundler2Default(engine, rubyVersion)) {
// If Bundler 1 is specified on Rubies which ship with Bundler 2,
// we need to specify which Bundler version to use explicitly until the lockfile exists.
console.log(`Setting BUNDLER_VERSION=${bundlerVersion} for "bundle config|lock" commands below to ensure Bundler 1 is used`)
envOptions = { env: { ...process.env, BUNDLER_VERSION: bundlerVersion } }
}

// config
const cachePath = 'vendor/bundle'
// An absolute path, so it is reliably under $PWD/vendor/bundle, and not relative to the gemfile's directory
const bundleCachePath = path.join(process.cwd(), cachePath)

await exec.exec('bundle', ['config', '--local', 'path', bundleCachePath])
await exec.exec('bundle', ['config', '--local', 'path', bundleCachePath], envOptions)

if (fs.existsSync(lockFile)) {
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'])
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'], envOptions)
} else {
// Generate the lockfile so we can use it to compute the cache key.
// This will also automatically pick up the latest gem versions compatible with the Gemfile.
await exec.exec('bundle', ['lock'])
await exec.exec('bundle', ['lock'], envOptions)
}

await afterLockFile(lockFile, platform, engine, rubyVersion)
Expand Down
24 changes: 12 additions & 12 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 93287a1

Please sign in to comment.