Repository navigation
Extension cannot resolve modules in custom queries #4230
Description
Activity
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.
- Tell the extension to use the same CLI bundle that you ran on the command line, by putting the path to the
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.
Reacted by Zy Zhang
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:
My vscode is on windows 11, and the .ql file is on WSL2 linux.
To reproduce
create a directory:
ql-queries. cd to the directorycreate a file
qlpack.ymlwith content:run
codeql pack installcreate a file
query.qlwith content: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 packsreturns: