Open lorenzleutgeb opened 4 years ago
I can't reproduce the "only a single query can be executed" error here. It looks very weird; that message should only produced when there is more than one non-option argument, or the name specified does not in in .ql
.
Would you be able to supply the log files produced by giving a --logdir some-directory
too?
As a workaround while we figure out what's going on, you might have better luck with codeql database run-queries
which does want a directory.
OK, so this might be because the input file name did not match *.ql
. I have to admit that I cheated when submitting the bug, the file was called something else on my machine. Nevertheless, the output is very confusing:
> touch x
> mkdir out
> codeql query run --logdir=logs -d java-database -o out x
A fatal error occurred: [redacted]/out is a directory.
> rmdir out
> codeql query run --logdir=logs -d java-database -o out x
A fatal error occurred: The output location [redacted]/out is not a directory, so only a single query can be executed.
out
[2020-11-03 19:29:56] This is codeql query run --logdir=logs -d java-database -o out x
[2020-11-03 19:29:56] Exception caught at top level: [redacted]/out is a directory.
com.semmle.cli2.ql.RunCommand.executeSubcommand(RunCommand.java:84)
com.semmle.cli2.picocli.SubcommandCommon.call(SubcommandCommon.java:407)
com.semmle.cli2.picocli.SubcommandMaker.runMain(SubcommandMaker.java:182)
com.semmle.cli2.picocli.SubcommandMaker.runMain(SubcommandMaker.java:190)
com.semmle.cli2.CodeQL.main(CodeQL.java:89)
out
[2020-11-03 19:30:07] This is codeql query run --logdir=logs -d java-database -o out x
[2020-11-03 19:30:07] Calling plumbing command: codeql resolve ram --format=json
[2020-11-03 19:30:07] Plumbing command codeql resolve ram completed:
[
"-J-Xmx3973M",
"--off-heap-ram=3973"
]
[2020-11-03 19:30:07] Spawning plumbing command: execute queries -J-Xmx3973M --off-heap-ram=3973 --verbosity=progress --logdir=[redacted]/logs --ml-model-path= --native-library-path= --warnings=show --output=[redacted]/out -- [redacted]/java-database/db-java [redacted]/x
[2020-11-03 19:30:08] [ERROR] Spawned process exited abnormally (code 2; tried to run: [/nix/store/s5zfg5vzrfrfc3mqyh3g0r4r6mpqc2g1-codeql-2.2.3/codeql/tools/linux64/java/bin/java, -Xmx3973M, -Djava.library.path=/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib, -cp, /nix/store/s5zfg5vzrfrfc3mqyh3g0r4r6mpqc2g1-codeql-2.2.3/codeql/tools/codeql.jar, com.semmle.cli2.CodeQL, execute, queries, -J-Xmx3973M, --off-heap-ram=3973, --verbosity=progress, --logdir=[redacted]/logs, --ml-model-path=, --native-library-path=, --warnings=show, --output=[redacted]/out, --, [redacted]/java-database/db-java, [redacted]/x])
[2020-11-03 19:30:08] Plumbing command codeql execute queries terminated with status 2.
[2020-11-03 19:30:08] Exiting with code 2
[2020-11-03 19:30:08] This is codeql execute queries -J-Xmx3973M --off-heap-ram=3973 --verbosity=progress --logdir=[redacted]/logs --ml-model-path= --native-library-path= --warnings=show --output=[redacted]/out -- [redacted]/java-database/db-java [redacted]/x
[2020-11-03 19:30:08] Exception caught at top level: The output location [redacted]/out is not a directory, so only a single query can be executed.
com.semmle.cli2.execute.ExecuteQueriesCommand.executeSubcommand(ExecuteQueriesCommand.java:110)
com.semmle.cli2.picocli.SubcommandCommon.call(SubcommandCommon.java:407)
com.semmle.cli2.picocli.SubcommandMaker.runMain(SubcommandMaker.java:182)
com.semmle.cli2.picocli.SubcommandMaker.runMain(SubcommandMaker.java:190)
com.semmle.cli2.CodeQL.main(CodeQL.java:89)
Yes, that would explain it.
The CLI uses file extensions to distinguish between whether the file being named is a query (*.ql
) or a query suite definition (*.qls
). Even though codeql query run
cannot run query suites, the execution eventually gets handled by general shared code that can.
We will consider ways to improve the error message to be less confusing in future releases. Thanks for the report.
overrides.ql
is taken from https://help.semmle.com/QL/learn-ql/java/annotations.html