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

Add codeql executable to PATH of VS Code Terminal #3006

Open
Marcono1234 opened this issue Oct 21, 2023 · 2 comments
Open

Add codeql executable to PATH of VS Code Terminal #3006

Marcono1234 opened this issue Oct 21, 2023 · 2 comments
Labels
enhancement New feature or request VSCode

Comments

@Marcono1234
Copy link
Contributor

Marcono1234 commented Oct 21, 2023

Is your feature request related to a problem? Please describe.
In some cases it is still necessary to use the CodeQL CLI, such as for creating a database (see also #306). If you don't want to manually install the CodeQL CLI but instead want to rely on the extension installing the latest version, this is a bit cumbersome because the executable is not by default available on the PATH, and its directory name (the distributionX part) changes after every CodeQL CLI update.

Describe the solution you'd like
At least the extension could make the codeql executable available in the VS Code Terminal, see for example https://code.visualstudio.com/updates/v1_46#_environment-variable-collection, and possibly related microsoft/vscode-python#11039 (might contain useful information and links).

Open questions:

  • Should this be opt-in / opt-out (or always active without being possible to deactivate)?
  • Should it prepend or append the CodeQL CLI directory to the PATH?
    (would make a difference if the user has already another codeql executable on the PATH)
  • Will this correctly handle CodeQL CLI updates performed by the extension (automatic or manually triggered)?
    (or will codeql not be available in all open terminals afterwards anymore)
  • Will this correctly handle setting a custom CodeQL CLI path in the settings while the extension is running?
    (and what is the 'correct' behavior? maybe it is desired that already open Terminals keep using the previously used CodeQL CLI)
  • Will codeql be available in the Terminal even if the extension hasn't been activated yet?
    (looks like this is the case if the extension had been activated previously when VS Code was open; not sure why this works)

As proof of concept I added locally the following to the activate function in extension.ts:

const collection = ctx.environmentVariableCollection;
const separator = process.platform === "win32" ? ";" : ":";
collection.prepend(
  "PATH",
  `C:\\Users\\user\\AppData\\Roaming\\Code\\User\\globalStorage\\github.vscode-codeql\\distribution16\\codeql${separator}`,
);

And that seems to work, making codeql available in the VS Code Terminal (if opened after the extension has been activated).

Describe alternatives you've considered

  • Let the extension add the CodeQL CLI globally to the PATH, so it is available even outside of VS Code
    Probably not easily possible in a portable way, might make it difficult to update the PATH when the CodeQL CLI is updated, and might also not properly update the PATH when the extension is uninstalled.
  • The user has to manually install CodeQL CLI, add it to the PATH and specify it in the extension settings
    They won't receive automatic updates this way though.
@Marcono1234 Marcono1234 added the enhancement New feature or request label Oct 21, 2023
@jf205
Copy link
Contributor

jf205 commented Oct 23, 2023

Hi @Marcono1234

Thanks for the feedback and suggestion. This is something we have thought about in the past but haven't had time to implement. We take another look at it as we plan further improvements to the CodeQL extension.

@amitjoshi438
Copy link

Hi @jf205

Our team is also looking forward to this; it will help us avoid the custom installation of CodeQL CLI for our customers. Are there any planned timelines for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request VSCode
Projects
None yet
Development

No branches or pull requests

3 participants