Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(manager/bundler): Multiple indications of strict mode failure #26946

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 34 additions & 1 deletion lib/modules/manager/bundler/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ describe('modules/manager/bundler/artifacts', () => {
]);
});

it('handles failure of strict updating', async () => {
it('handles failure of strict updating for version solving', async () => {
const execError = new ExecError('Exec error', {
cmd: '',
stdout: '',
Expand Down Expand Up @@ -913,6 +913,39 @@ describe('modules/manager/bundler/artifacts', () => {
{ cmd: 'bundler lock --minor --conservative --update foo' },
]);
});

it('handles failure of strict updating for missing gem', async () => {
// See https://github.com/rubygems/rubygems/issues/7369
const execError = new ExecError('Exec error', {
cmd: '',
stdout: '',
stderr: "Could not find gems matching 'foo ",
options: { encoding: 'utf8' },
});
fs.readLocalFile.mockResolvedValue('Current Gemfile.lock');
const execSnapshots = mockExecSequence([
execError,
{ stdout: '', stderr: '' },
]);
git.getRepoStatus.mockResolvedValueOnce(
partial<StatusResult>({
modified: ['Gemfile.lock'],
}),
);

const res = await updateArtifacts({
packageFileName: 'Gemfile',
updatedDeps: [{ depName: 'foo', updateType: 'minor' }],
newPackageFileContent: '{}',
config,
});

expect(res).toMatchObject([{ file: { path: 'Gemfile.lock' } }]);
expect(execSnapshots).toMatchObject([
{ cmd: 'bundler lock --minor --strict --update foo' },
{ cmd: 'bundler lock --minor --conservative --update foo' },
]);
});
});
});
});
6 changes: 5 additions & 1 deletion lib/modules/manager/bundler/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ export async function updateArtifacts(
memCache.set('bundlerArtifactsError', BUNDLER_INVALID_CREDENTIALS);
throw new Error(BUNDLER_INVALID_CREDENTIALS);
}
if (recursionLimit > 0 && output.includes('version solving has failed')) {
if (
recursionLimit > 0 &&
(output.includes('version solving has failed') ||
output.includes('Could not find gem'))
) {
logger.debug('Failed to lock strictly, retrying non-strict');
const newConfig = {
...config,
Expand Down