Add a better error message for users of CodeQL CLI 2.7.2 and earlier

Improves the error message for users running (a) CLI 2.7.2 and earlier
and (b) `ubuntu-22.04`, to which `ubuntu-latest` is now being migrated.
Previously this was "undefined symbol: __libc_dlopen_mode, version
GLIBC_PRIVATE".
Now we give some guidance around glibc versions and using the
`ubuntu-20.04` runner image.
This commit is contained in:
Henry Mercer 2022-10-28 18:38:00 +01:00
parent 40542d38bc
commit a12a861b82
3 changed files with 79 additions and 21 deletions

View file

@ -48,7 +48,12 @@ interface ExtraOptions {
}
export class CommandInvocationError extends Error {
constructor(cmd: string, args: string[], exitCode: number, error: string) {
constructor(
cmd: string,
args: string[],
exitCode: number,
public error: string
) {
super(
`Failure invoking ${cmd} with arguments ${args}.\n
Exit code ${exitCode} and error was:\n
@ -263,6 +268,12 @@ export const CODEQL_VERSION_GHES_PACK_DOWNLOAD = "2.10.4";
*/
export const CODEQL_VERSION_NEW_TRACING = "2.7.0";
/**
* Versions 2.7.3+ of the CodeQL CLI support build tracing with glibc 2.34 on Linux. Versions before
* this cannot perform build tracing when running on the Actions `ubuntu-22.04` runner image.
*/
export const CODEQL_VERSION_TRACING_GLIBC_2_34 = "2.7.3";
/**
* Versions 2.9.0+ of the CodeQL CLI run machine learning models from a temporary directory, which
* resolves an issue on Windows where TensorFlow models are not correctly loaded due to the path of
@ -742,15 +753,39 @@ async function getCodeQLForCmd(
// _and_ is present in the latest supported CLI release.)
const envFile = path.resolve(databasePath, "working", "env.tmp");
await runTool(cmd, [
"database",
"trace-command",
databasePath,
...getExtraOptionsFromEnv(["database", "trace-command"]),
process.execPath,
tracerEnvJs,
envFile,
]);
try {
await runTool(cmd, [
"database",
"trace-command",
databasePath,
...getExtraOptionsFromEnv(["database", "trace-command"]),
process.execPath,
tracerEnvJs,
envFile,
]);
} catch (e) {
if (
e instanceof CommandInvocationError &&
e.error.includes(
"undefined symbol: __libc_dlopen_mode, version GLIBC_PRIVATE"
) &&
process.platform === "linux" &&
!(await util.codeQlVersionAbove(
this,
CODEQL_VERSION_TRACING_GLIBC_2_34
))
) {
throw new util.UserError(
"The CodeQL CLI is incompatible with the version of glibc on your system. " +
`Please upgrade to CodeQL CLI version ${CODEQL_VERSION_TRACING_GLIBC_2_34} or ` +
"later. If you cannot upgrade to a newer version of the CodeQL CLI, you can " +
"alternatively use glibc 2.33 or earlier, for instance by running your workflow on " +
`the "ubuntu-20.04" runner image.`
);
} else {
throw e;
}
}
return JSON.parse(fs.readFileSync(envFile, "utf-8"));
},
async databaseInit(