mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
[ruby] Handle exit code 18 gracefully (#8388)
This reverts #8381 and instead supports the "2.7.x" syntax. - Related to https://github.com/vercel/customer-issues/issues/684
This commit is contained in:
@@ -47,30 +47,32 @@ async function bundleInstall(
|
||||
) {
|
||||
debug(`running "bundle install --deployment"...`);
|
||||
const bundleAppConfig = await getWriteableDirectory();
|
||||
const { exitCode, stderr, stdout } = await execa(
|
||||
bundlePath,
|
||||
['install', '--deployment', '--gemfile', gemfilePath, '--path', bundleDir],
|
||||
{
|
||||
stdio: 'pipe',
|
||||
reject: false,
|
||||
env: {
|
||||
...process.env,
|
||||
BUNDLE_SILENCE_ROOT_WARNING: '1',
|
||||
BUNDLE_APP_CONFIG: bundleAppConfig,
|
||||
BUNDLE_JOBS: '4',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
await execa(
|
||||
bundlePath,
|
||||
[
|
||||
'install',
|
||||
'--deployment',
|
||||
'--gemfile',
|
||||
gemfilePath,
|
||||
'--path',
|
||||
bundleDir,
|
||||
],
|
||||
{
|
||||
stdio: 'pipe',
|
||||
env: {
|
||||
BUNDLE_SILENCE_ROOT_WARNING: '1',
|
||||
BUNDLE_APP_CONFIG: bundleAppConfig,
|
||||
BUNDLE_JOBS: '4',
|
||||
},
|
||||
}
|
||||
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}`
|
||||
);
|
||||
} catch (err) {
|
||||
debug(`failed to run "bundle install --deployment"...`);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,14 +144,7 @@ export async function build({
|
||||
} else {
|
||||
// try installing. this won't work if native extesions are required.
|
||||
// if that's the case, gems should be vendored locally before deploying.
|
||||
try {
|
||||
await bundleInstall(bundlerPath, bundleDir, gemfilePath);
|
||||
} catch (err) {
|
||||
debug(
|
||||
'unable to build gems from Gemfile. vendor the gems locally with "bundle install --deployment" and retry.'
|
||||
);
|
||||
throw err;
|
||||
}
|
||||
await bundleInstall(bundlerPath, bundleDir, gemfilePath);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user