codeql-cli-binaries icon indicating copy to clipboard operation
codeql-cli-binaries copied to clipboard

ERROR: Could not detect a suitable build command for the source checkout

Open neupaneprakash opened this issue 2 years ago • 2 comments

  1. `codeql database create java_db1 --language=java --source-root Java/
  2. Initializing database at /home/prakash/java_db1.
  3. Running build command: [/home/prakash/codeql/java/tools/autobuild.sh]
  4. [2022-11-11 11:29:36] [build-stderr] ERROR: Could not detect a suitable build command for the source checkout.
  5. [2022-11-11 11:29:36] [ERROR] Spawned process exited abnormally (code 1; tried to run: [/home/prakash/codeql/tools/linux64/preload_tracer, /home/prakash/codeql/java/tools/autobuild.sh])
  6. A fatal error occurred: Exit status 1 from command: [/home/prakash/codeql/java/tools/autobuild.sh] `

Above log is generated while executing database create command. I was simply trying to create codeql database for java with single java file named TestClass.java inside the Java directory but I am not being able to create database successfully.
For your reference I am attaching the java source code here : https://www.dropbox.com/sh/q1t648a3imvmesk/AAAxoRWnihrO2oYiBrDQICWQa?dl=0 Anyone can help ASAP?

neupaneprakash avatar Nov 11 '22 06:11 neupaneprakash

CodeQL analysis for Java needs to compile the Java source code in order to analyze it. The "autobuilder" is a small program that tries to automatically figure out how to build the code base. It supports common build systems like gradle, maven and ant, and also picks up simple build scripts named build.sh or build.cmd (for windows).

CodeQL does not know how to compile a single Java file. Simply calling javac SoureFile.java is unlikely to work very often in practice, because you'd normally need to add dependencies to the classpath using the -cp flag.

In your case I'd recommend adding a simple build.sh file to your repo :

#! /bin/bash

javac TestClass.java

Alternatively you can invoke codeql with an explicit build command like codeql database create java_db1 --language=java --source-root Java/ --command "javac TestClass.java"

aibaars avatar Nov 11 '22 09:11 aibaars

Thank you!

On Fri, Nov 11, 2022 at 3:13 PM Arthur Baars @.***> wrote:

CodeQL analysis for Java needs to compile the Java source code in order to analyze it. The "autobuilder" is a small program that tries to automatically figure out how to build the code base. It supports common build systems like gradle, maven and ant, and also picks up simple build scripts named build.sh or build.cmd (for windows).

CodeQL does not know how to compile a single Java file. Simply calling javac SoureFile.java is unlikely to work very often in practice, because you'd normally need to add dependencies to the classpath using the -cp flag.

In your case I'd recommend adding a simple build.sh file to your repo :

#! /bin/bash

javac TestClass.java

Alternatively you can invoke codeql with an explicit build command like codeql database create java_db1 --language=java --source-root Java/ --command "javac TestClass.java"

— Reply to this email directly, view it on GitHub https://github.com/github/codeql-cli-binaries/issues/142#issuecomment-1311464710, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIZOPFT4Y55ZZK6SF5NTV3LWHYIL7ANCNFSM6AAAAAAR5JEOV4 . You are receiving this because you authored the thread.Message ID: @.***>

-- -- Thanks and regards, Prakash Neupane

M.S. (by Research) Scholar School of Computing and Electrical Engineering Indian Institute of Technology, Mandi *LinkedIn: *https://www.linkedin.com/in/ncprakash/ Web: https://neupaneprakash.github.io/ http://nprakash.com.np/

neupaneprakash avatar Nov 12 '22 13:11 neupaneprakash