diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index 61c910aa25a..f6c17adce8f 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -2,6 +2,8 @@ ## [UNRELEASED] +- Fixed a bug where copying the version information fails when a CodeQL CLI cannot be found. [#958](https://github.com/github/vscode-codeql/pull/958) + ## 1.5.5 - 08 September 2021 - Fix bug where a query is sometimes run before the file is saved. [#947](https://github.com/github/vscode-codeql/pull/947) diff --git a/extensions/ql-vscode/src/extension.ts b/extensions/ql-vscode/src/extension.ts index 7fedd49a722..f435013dddd 100644 --- a/extensions/ql-vscode/src/extension.ts +++ b/extensions/ql-vscode/src/extension.ts @@ -792,11 +792,19 @@ async function activateWithInstalledDistribution( ctx.subscriptions.push( commandRunner('codeQL.copyVersion', async () => { - const text = `CodeQL extension version: ${extension?.packageJSON.version} \nCodeQL CLI version: ${await cliServer.getVersion()} \nPlatform: ${os.platform()} ${os.arch()}`; + const text = `CodeQL extension version: ${extension?.packageJSON.version} \nCodeQL CLI version: ${await getCliVersion()} \nPlatform: ${os.platform()} ${os.arch()}`; await env.clipboard.writeText(text); void helpers.showAndLogInformationMessage(text); })); + const getCliVersion = async () => { + try { + return await cliServer.getVersion(); + } catch { + return ''; + } + }; + // The "authenticateToGitHub" command is internal-only. ctx.subscriptions.push( commandRunner('codeQL.authenticateToGitHub', async () => {