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(bundler): Set exec cwd to lock file #24379

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/modules/manager/bundler/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export async function updateArtifacts(
logger.debug('Aborting Bundler artifacts due to previous failed attempt');
throw new Error(existingError);
}
const lockFileName = await getLockFilePath(packageFileName);
viceice marked this conversation as resolved.
Show resolved Hide resolved
const existingLockFileContent = await readLocalFile(lockFileName, 'utf8');
const lockFilePath = await getLockFilePath(packageFileName);
const existingLockFileContent = await readLocalFile(lockFilePath, 'utf8');
if (!existingLockFileContent) {
logger.debug('No Gemfile.lock found');
return null;
Expand Down Expand Up @@ -174,7 +174,7 @@ export async function updateArtifacts(
}

const execOptions: ExecOptions = {
cwdFile: packageFileName,
cwdFile: lockFilePath,
extraEnv: {
...bundlerHostRulesVariables,
GEM_HOME: await ensureCacheDir('bundler'),
Expand All @@ -195,16 +195,16 @@ export async function updateArtifacts(
await exec(commands, execOptions);

const status = await getRepoStatus();
if (!status.modified.includes(lockFileName)) {
if (!status.modified.includes(lockFilePath)) {
return null;
}
logger.debug('Returning updated Gemfile.lock');
const lockFileContent = await readLocalFile(lockFileName);
const lockFileContent = await readLocalFile(lockFilePath);
return [
{
file: {
type: 'addition',
path: lockFileName,
path: lockFilePath,
contents: lockFileContent,
},
},
Expand All @@ -221,7 +221,7 @@ export async function updateArtifacts(
return [
{
artifactError: {
lockFile: lockFileName,
lockFile: lockFilePath,
stderr: output,
},
},
Expand Down Expand Up @@ -275,7 +275,7 @@ export async function updateArtifacts(
return [
{
artifactError: {
lockFile: lockFileName,
lockFile: lockFilePath,
stderr: `${String(err.stdout)}\n${String(err.stderr)}`,
},
},
Expand Down
5 changes: 3 additions & 2 deletions lib/modules/manager/bundler/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ export function getBundlerConstraint(
export async function getLockFilePath(
packageFilePath: string
): Promise<string> {
logger.debug(`Looking for lockfile for ${packageFilePath}`);
return (await localPathExists(`${packageFilePath}.lock`))
const lockFilePath = (await localPathExists(`${packageFilePath}.lock`))
? `${packageFilePath}.lock`
: `Gemfile.lock`;
logger.debug(`Lockfile for ${packageFilePath} found in ${lockFilePath}`);
return lockFilePath;
}