[ruby] Fix bundle install (#8392)

This PR is a follow up to #8388. The tests were not running as expected because only the "vendored" test used `2.7.x` which was never failing `bundle install` to begin with. I had to add `2.7.x` to the non-vendored test to get `bundle install` to fail. The fix is to rename `2.7.x` to `2.7.0` before running `bundle install`.
This commit is contained in:
Steven
2022-08-12 21:59:50 -04:00
committed by GitHub
parent b52d01f809
commit 37290039d6
2 changed files with 14 additions and 15 deletions

View File

@@ -47,12 +47,22 @@ async function bundleInstall(
) {
debug(`running "bundle install --deployment"...`);
const bundleAppConfig = await getWriteableDirectory();
const { exitCode, stderr, stdout } = await execa(
const gemfileContent = await readFile(gemfilePath, 'utf8');
if (gemfileContent.includes('ruby "~> 2.7.x"')) {
// Gemfile contains "2.7.x" which will cause an error message:
// "Your Ruby patchlevel is 0, but your Gemfile specified -1"
// See https://github.com/rubygems/bundler/blob/3f0638c6c8d340c2f2405ecb84eb3b39c433e36e/lib/bundler/errors.rb#L49
// We must correct to the actual version in the build container.
await writeFile(
gemfilePath,
gemfileContent.replace('ruby "~> 2.7.x"', 'ruby "~> 2.7.0"')
);
}
await execa(
bundlePath,
['install', '--deployment', '--gemfile', gemfilePath, '--path', bundleDir],
{
stdio: 'pipe',
reject: false,
env: {
...process.env,
BUNDLE_SILENCE_ROOT_WARNING: '1',
@@ -61,19 +71,6 @@ async function bundleInstall(
},
}
);
if (
exitCode === 0 ||
(exitCode === 18 && stderr.includes('Gemfile specified -1'))
) {
// Gemfile might contain "2.7.x" so install might exit with code 18 and message:
// "Your Ruby patchlevel is 0, but your Gemfile specified -1"
// See https://github.com/rubygems/bundler/blob/3f0638c6c8d340c2f2405ecb84eb3b39c433e36e/lib/bundler/errors.rb#L49
} else {
throw new Error(
`"bundle install" failed with exit code ${exitCode}: ${stdout}\n${stderr}`
);
}
}
export const version = 3;