Repository navigation
Extension cannot resolve modules in custom queries #4230
Copy link
Copy link
Closed
Labels
Description
Describe the bug
In a custom query, the extension seems to fail to import libraries, causing all imports are highlighted in error with message like could not resolve module java.
Version
CodeQL extension version: 1.17.7 CodeQL CLI version: 2.23.7 Platform: linux x64
vscode version:
Version: 1.106.3 (user setup)
Commit: bf9252a2fb45be6893dd8870c0bf37e2e1766d61
Date: 2025-11-25T22:28:18.024Z
Electron: 37.7.0
ElectronBuildId: 12781156
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26200
My vscode is on windows 11, and the .ql file is on WSL2 linux.
To reproduce
-
create a directory:
ql-queries. cd to the directory -
create a file
qlpack.ymlwith content:name: ql-queries version: 1.0.0 dependencies: codeql/java-queries: ^1.10.2 -
run
codeql pack install -
create a file
query.qlwith content:/** * @name aaa * @description Finds xxx * @kind path-problem * @problem.severity error * @id java/custom/xxx */ import java import semmle.code.java.dataflow.DataFlow import semmle.code.java.dataflow.TaintTracking import semmle.code.java.Expr import semmle.code.java.Member
Expected behavior
The extension reports no error and can import the modules.
Additional context
codeql is installed on WSL2 linux from the released bundle. codeql resolve packs returns:
Searching directories specified by `--additional-packs`. All directories have equal priority.
Searching in:
No packs were found at this location.
Searching directories specified by `--search-path`. Directories are searched in order.
Searching the root of the CodeQL distribution.
Searching in:
/home/me/software/codeql
The following packs were found:
codeql/actions-all@0.4.22: (library) /home/me/software/codeql/qlpacks/codeql/actions-all/0.4.22/qlpack.yml
codeql/actions-queries@0.6.14: (query) /home/me/software/codeql/qlpacks/codeql/actions-queries/0.6.14/qlpack.yml
codeql/concepts@0.0.10: (library) /home/me/software/codeql/qlpacks/codeql/concepts/0.0.10/qlpack.yml
codeql/controlflow@2.0.20: (library) /home/me/software/codeql/qlpacks/codeql/controlflow/2.0.20/qlpack.yml
codeql/cpp-all@6.1.1: (library) /home/me/software/codeql/qlpacks/codeql/cpp-all/6.1.1/qlpack.yml
codeql/cpp-examples@0.0.0: (query) /home/me/software/codeql/qlpacks/codeql/cpp-examples/0.0.0/qlpack.yml
codeql/cpp-queries@1.5.5: (query) /home/me/software/codeql/qlpacks/codeql/cpp-queries/1.5.5/qlpack.yml
codeql/csharp-all@5.4.1: (library) /home/me/software/codeql/qlpacks/codeql/csharp-all/5.4.1/qlpack.yml
codeql/csharp-examples@0.0.0: (query) /home/me/software/codeql/qlpacks/codeql/csharp-examples/0.0.0/qlpack.yml
codeql/csharp-queries@1.5.1: (query) /home/me/software/codeql/qlpacks/codeql/csharp-queries/1.5.1/qlpack.yml
codeql/dataflow@2.0.20: (library) /home/me/software/codeql/qlpacks/codeql/dataflow/2.0.20/qlpack.yml
codeql/go-all@5.0.3: (library) /home/me/software/codeql/qlpacks/codeql/go-all/5.0.3/qlpack.yml
codeql/go-examples@0.0.0: (query) /home/me/software/codeql/qlpacks/codeql/go-examples/0.0.0/qlpack.yml
codeql/go-queries@1.5.0: (query) /home/me/software/codeql/qlpacks/codeql/go-queries/1.5.0/qlpack.yml
codeql/java-all@7.8.0: (library) /home/me/software/codeql/qlpacks/codeql/java-all/7.8.0/qlpack.yml
codeql/java-examples@0.0.0: (query) /home/me/software/codeql/qlpacks/codeql/java-examples/0.0.0/qlpack.yml
codeql/java-queries@1.10.1: (query) /home/me/software/codeql/qlpacks/codeql/java-queries/1.10.1/qlpack.yml
codeql/javascript-all@2.6.16: (library) /home/me/software/codeql/qlpacks/codeql/javascript-all/2.6.16/qlpack.yml
codeql/javascript-examples@0.0.0: (query) /home/me/software/codeql/qlpacks/codeql/javascript-examples/0.0.0/qlpack.yml
codeql/javascript-queries@2.2.1: (query) /home/me/software/codeql/qlpacks/codeql/javascript-queries/2.2.1/qlpack.yml
codeql/mad@1.0.36: (library) /home/me/software/codeql/qlpacks/codeql/mad/1.0.36/qlpack.yml
codeql/python-all@5.0.1: (library) /home/me/software/codeql/qlpacks/codeql/python-all/5.0.1/qlpack.yml
codeql/python-examples@0.0.0: (query) /home/me/software/codeql/qlpacks/codeql/python-examples/0.0.0/qlpack.yml
codeql/python-queries@1.7.1: (query) /home/me/software/codeql/qlpacks/codeql/python-queries/1.7.1/qlpack.yml
codeql/quantum@0.0.14: (library) /home/me/software/codeql/qlpacks/codeql/quantum/0.0.14/qlpack.yml
codeql/rangeanalysis@1.0.36: (library) /home/me/software/codeql/qlpacks/codeql/rangeanalysis/1.0.36/qlpack.yml
codeql/regex@1.0.36: (library) /home/me/software/codeql/qlpacks/codeql/regex/1.0.36/qlpack.yml
codeql/ruby-all@5.1.4: (library) /home/me/software/codeql/qlpacks/codeql/ruby-all/5.1.4/qlpack.yml
codeql/ruby-examples@0.0.0: (query) /home/me/software/codeql/qlpacks/codeql/ruby-examples/0.0.0/qlpack.yml
codeql/ruby-queries@1.5.1: (query) /home/me/software/codeql/qlpacks/codeql/ruby-queries/1.5.1/qlpack.yml
codeql/rust-all@0.2.0: (library) /home/me/software/codeql/qlpacks/codeql/rust-all/0.2.0/qlpack.yml
codeql/rust-queries@0.1.21: (query) /home/me/software/codeql/qlpacks/codeql/rust-queries/0.1.21/qlpack.yml
codeql/ssa@2.0.12: (library) /home/me/software/codeql/qlpacks/codeql/ssa/2.0.12/qlpack.yml
codeql/suite-helpers@1.0.36: (query) /home/me/software/codeql/qlpacks/codeql/suite-helpers/1.0.36/qlpack.yml
codeql/swift-all@6.1.1: (library) /home/me/software/codeql/qlpacks/codeql/swift-all/6.1.1/qlpack.yml
codeql/swift-queries@1.2.10: (query) /home/me/software/codeql/qlpacks/codeql/swift-queries/1.2.10/qlpack.yml
codeql/threat-models@1.0.36: (library) /home/me/software/codeql/qlpacks/codeql/threat-models/1.0.36/qlpack.yml
codeql/tutorial@1.0.36: (library) /home/me/software/codeql/qlpacks/codeql/tutorial/1.0.36/qlpack.yml
codeql/typeflow@1.0.36: (library) /home/me/software/codeql/qlpacks/codeql/typeflow/1.0.36/qlpack.yml
codeql/typeinference@0.0.17: (library) /home/me/software/codeql/qlpacks/codeql/typeinference/0.0.17/qlpack.yml
codeql/typetracking@2.0.20: (library) /home/me/software/codeql/qlpacks/codeql/typetracking/2.0.20/qlpack.yml
codeql/typos@1.0.36: (library) /home/me/software/codeql/qlpacks/codeql/typos/1.0.36/qlpack.yml
codeql/util@2.0.23: (library) /home/me/software/codeql/qlpacks/codeql/util/2.0.23/qlpack.yml
codeql/xml@1.0.36: (library) /home/me/software/codeql/qlpacks/codeql/xml/1.0.36/qlpack.yml
codeql/yaml@1.0.36: (library) /home/me/software/codeql/qlpacks/codeql/yaml/1.0.36/qlpack.yml
legacy-upgrades@0.0.0: (query) /home/me/software/codeql/legacy-upgrades/qlpack.yml
Searching the parent directory of the CodeQL distribution.
Searching in:
/home/me/software
Some packs were hidden by previously found packs. Use --show-hidden-packs to see them.
Searching the local pack cache. This only applies when searching for a particular version of a pack specified in a lock file.
Searching in: /home/me/.codeql/packages
No packs were found at this location.
Reactions are currently unavailable
Activity
nickrolfe commentedon Dec 9, 2025
Hi @Ryvian — you say you are running the CodeQL CLI from WSL. Are you also using the WSL functionality in VS Code (e.g. running "WSL: Connect to WSL" before opening the folder)? If not, then the CodeQL extension's language server will be running using a Windows CLI, and I would not expect that to see or pick up anything under the WSL filesystem.
To help see what's happening, I suggest opening the Output pane in VS Code, then selecting "CodeQL Language Server" in the dropdown menu, and scrolling to the top. Right at the top, you should be able to see whether it's running a Windows or Linux CLI for the language server.
A few lines down, you should see a message containing the text
The listed library paths will show you where it's looking for installed packages.
Ryvian commentedon Dec 10, 2025
Hi @nickrolfe ! Yes I connected vscode to WSL and it seemed CodeQL language server was running on WSL because the Output of "CodeQL Language Server" was
Do you know what could go wrong? Thank you
nickrolfe commentedon Dec 10, 2025
Thanks — I think we can rule out WSL being the cause of the problem.
I assume you are using a manually-downloaded CLI bundle when running on the command line, while I can see that the VS Code extension is managing its own CLI installation to use as the language server (
/home/me/.vscode-server/data/User/globalStorage/github.vscode-codeql/distribution1/codeql/codeql). I can suggest a couple of things to try:codeqlexecutable in thecodeQL.cli.executablePathsetting in the VS Code settings.Ryvian commentedon Dec 11, 2025
Thanks! 1 solves the problem. However, the dignostics at the start was OK but after some code edits it became sluggish and failed to load hover messages when the mouse moved over code constructs. The Output of CodeQL language server is
Do you know how to fix it?
nickrolfe commentedon Dec 15, 2025
If you see this happen persistently, I'm afraid it just means the language server needs more memory than it was able to claim (that amount is derived from the total system memory).
It looks like WSL2 memory is capped at 50% of the host memory by default and I assume the Linux kernel running inside the VM uses some of that. You might want to consider increasing the amount of memory WSL2 is allowed to use.