Extension cannot resolve modules in custom queries
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/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/actions-all/0.4.22/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/actions-queries/0.6.14/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/concepts/0.0.10/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/controlflow/2.0.20/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/cpp-all/6.1.1/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/cpp-examples/0.0.0/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/cpp-queries/1.5.5/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/csharp-all/5.4.1/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/csharp-examples/0.0.0/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/csharp-queries/1.5.1/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/dataflow/2.0.20/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/go-all/5.0.3/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/go-examples/0.0.0/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/go-queries/1.5.0/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/java-all/7.8.0/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/java-examples/0.0.0/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/java-queries/1.10.1/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/javascript-all/2.6.16/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/javascript-examples/0.0.0/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/javascript-queries/2.2.1/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/mad/1.0.36/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/python-all/5.0.1/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/python-examples/0.0.0/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/python-queries/1.7.1/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/quantum/0.0.14/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/rangeanalysis/1.0.36/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/regex/1.0.36/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/ruby-all/5.1.4/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/ruby-examples/0.0.0/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/ruby-queries/1.5.1/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/rust-all/0.2.0/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/rust-queries/0.1.21/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/ssa/2.0.12/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/suite-helpers/1.0.36/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/swift-all/6.1.1/qlpack.yml
codeql/[email protected]: (query) /home/me/software/codeql/qlpacks/codeql/swift-queries/1.2.10/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/threat-models/1.0.36/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/tutorial/1.0.36/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/typeflow/1.0.36/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/typeinference/0.0.17/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/typetracking/2.0.20/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/typos/1.0.36/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/util/2.0.23/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/xml/1.0.36/qlpack.yml
codeql/[email protected]: (library) /home/me/software/codeql/qlpacks/codeql/yaml/1.0.36/qlpack.yml
[email protected]: (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.
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
Creating pack state at .../ql-queries, with library path [...
The listed library paths will show you where it's looking for installed packages.
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
Starting CodeQL language server using CodeQL CLI: /home/me/.vscode-server/data/User/globalStorage/github.vscode-codeql/distribution1/codeql/codeql execute language-server --check-errors ON_CHANGE -v --log-to-stderr
CodeQL language server started on PID: 4656
[2025-12-09 21:51:19] This is codeql execute language-server --check-errors ON_CHANGE -v --log-to-stderr
[2025-12-09 21:51:19] Stale frontend caches are invalidated based on fine-grained dependency tracking.
Content-Length: 793
......
Do you know what could go wrong? Thank you
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:
- Tell the extension to use the same CLI bundle that you ran on the command line, by putting the path to the
codeqlexecutable in thecodeQL.cli.executablePathsetting in the VS Code settings. - Alternatively, try downloading the packs via the extension.
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
[Error - 11:31:15 PM] Request textDocument/inlayHint failed.
Message: Internal error.
Code: -32603
java.util.concurrent.CompletionException: java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Java heap space
at com.semmle.util.data.MultiMap.<init>(MultiMap.java:92)
at com.semmle.util.data.MultiMap.<init>(MultiMap.java:80)
at com.semmle.frontend.analysis.binding2.AliasBindingEnvironment.getAllDeclared(AliasBindingEnvironment.java:110)
at com.semmle.frontend.analysis.binding2.AllBinder.getAllInternal(AllBinder.java:282)
at com.semmle.frontend.analysis.binding2.AllBinder.lambda$new$7(AllBinder.java:62)
at com.semmle.frontend.analysis.binding2.AllBinder$$Lambda/0x00000001001b4a40.apply(Unknown Source)
at com.semmle.frontend.analysis.binding2.IncrementalBindingCache$CacheImpl.apply(IncrementalBindingCache.java:333)
at com.semmle.frontend.analysis.binding2.IncrementalBindingCache$CacheImpl.apply(IncrementalBindingCache.java:283)
at com.semmle.frontend.analysis.binding2.AbstractBindingCache$AbstractCacheImpl.get(AbstractBindingCache.java:366)
at com.semmle.frontend.analysis.binding2.IncrementalBindingCache$CacheImpl.get(IncrementalBindingCache.java:310)
at com.semmle.frontend.analysis.binding2.AllBinder.getAllVisible(AllBinder.java:138)
at com.semmle.frontend.analysis.binding2.AllBinder.getAllInternal(AllBinder.java:296)
at com.semmle.frontend.analysis.binding2.AllBinder.lambda$new$7(AllBinder.java:62)
at com.semmle.frontend.analysis.binding2.AllBinder$$Lambda/0x00000001001b4a40.apply(Unknown Source)
at com.semmle.frontend.analysis.binding2.IncrementalBindingCache$CacheImpl.apply(IncrementalBindingCache.java:333)
at com.semmle.frontend.analysis.binding2.IncrementalBindingCache$CacheImpl.apply(IncrementalBindingCache.java:283)
at com.semmle.frontend.analysis.binding2.AbstractBindingCache$AbstractCacheImpl.get(AbstractBindingCache.java:366)
at com.semmle.frontend.analysis.binding2.IncrementalBindingCache$CacheImpl.get(IncrementalBindingCache.java:310)
at com.semmle.frontend.analysis.binding2.AllBinder.getAllVisible(AllBinder.java:138)
at com.semmle.frontend.analysis.binding2.BindingEnvironment.getAllVisible(BindingEnvironment.java:99)
at com.semmle.frontend.analysis.binding2.QLBindingContext2.getAllVisible(QLBindingContext2.java:498)
at com.semmle.frontend.analysis.binding2.QLBindingContext2.getVisible(QLBindingContext2.java:511)
at com.semmle.frontend.analysis.binding2.PredicateBodyEnv.resolveCallTargetsImpl(PredicateBodyEnv.java:973)
at com.semmle.frontend.analysis.binding2.PredicateBodyEnv$$Lambda/0x0000000100209fc8.apply(Unknown Source)
at com.semmle.frontend.analysis.binding2.IncrementalBindingCache$CacheImpl.apply(IncrementalBindingCache.java:333)
at com.semmle.frontend.analysis.binding2.IncrementalBindingCache$CacheImpl.apply(IncrementalBindingCache.java:283)
at com.semmle.frontend.analysis.binding2.AbstractBindingCache$AbstractCacheImpl.get(AbstractBindingCache.java:366)
at com.semmle.frontend.analysis.binding2.IncrementalBindingCache$CacheImpl.get(IncrementalBindingCache.java:310)
at com.semmle.frontend.analysis.binding2.PredicateBodyEnv.resolveCallTargets(PredicateBodyEnv.java:339)
at com.semmle.frontend.ast.Call.getWeakBindings(Call.java:73)
at com.semmle.frontend.ast.Call.getStrongBinding(Call.java:78)
at com.semmle.frontend.ast.ReferenceExpr.getEntity(ReferenceExpr.java:75)
[2025-12-11 23:31:58] ExternalModuleBindingPass ...
[2025-12-11 23:31:58] ExternalModuleBindingPass time: 00:00.000
[2025-12-11 23:31:58] CollectInstantiationsPass ...
[2025-12-11 23:31:58] CollectInstantiationsPass time: 00:00.000
[2025-12-11 23:32:07] ExternalModuleBindingPass ...
[2025-12-11 23:32:07] ExternalModuleBindingPass time: 00:00.000
[2025-12-11 23:32:07] CollectInstantiationsPass ...
[2025-12-11 23:32:07] CollectInstantiationsPass time: 00:00.000
Content-Length: 141
{"jsonrpc":"2.0","id":51,"error":{"code":-32800,"message":"The request (id: 51, method: \u0027textDocument/hover\u0027) has been cancelled"}}
Do you know how to fix it?
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.