Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A fatal error occurred: The CodeQL database is not compatible with a QL library referenced by the query you are trying to run.General issue #8763

Closed
greenpau opened this issue Apr 16, 2022 · 9 comments
Labels
question Further information is requested

Comments

@greenpau
Copy link

Description of the issue

Running the following command:

codeql database run-queries --ram=5922 --threads=2 --verbose   -- ./databases/go-authcrunch   ./queries-go/ql/src/codeql-suites/go-lgtm.qls

I get the above error:

Writing logs to /home/greenpau/.local/codeql/databases/go-authcrunch/log/database-run-queries-20220416.172120.360.log.
Writing logs to /home/greenpau/.local/codeql/databases/go-authcrunch/log/execute-queries-20220416.172121.028.log.
Compiling in one thread due to RAM limits.
Compiling query plan for /home/greenpau/.local/codeql/queries-go/ql/src/InconsistentCode/ConstantLengthComparison.ql.
Resolving imports for /home/greenpau/.local/codeql/queries-go/ql/src/InconsistentCode/ConstantLengthComparison.ql.
Checking QL for /home/greenpau/.local/codeql/queries-go/ql/src/InconsistentCode/ConstantLengthComparison.ql.
Optimizing /home/greenpau/.local/codeql/queries-go/ql/src/InconsistentCode/ConstantLengthComparison.ql.
Resolving database upgrade for /home/greenpau/.local/codeql/queries-go/ql/src/InconsistentCode/ConstantLengthComparison.ql
Resolving database downgrade for /home/greenpau/.local/codeql/queries-go/ql/src/InconsistentCode/ConstantLengthComparison.ql
A fatal error occurred: The CodeQL database is not compatible with a QL library referenced by the query you are trying to run.
        CodeQL database location: databases/go-authcrunch
        Query location: queries-go/ql/src/InconsistentCode/ConstantLengthComparison.ql
The database may be too new for the QL libraries the query is using; try upgrading them.
Alternatively, running 'codeql database upgrade databases/go-authcrunch' with an appropriate --search-path option might help.

Per the suggestion in the log, I try updating. It is up-to-date.

$ codeql database upgrade databases/go-authcrunch
/home/greenpau/.local/codeql/databases/go-authcrunch/db-go is up to date.
$ codeql version
CodeQL command-line toolchain release 2.8.5.

$codeql resolve qlpacks
codeql-cpp (/home/greenpau/.local/codeql/queries/cpp/ql/src)
codeql-cpp-examples (/home/greenpau/.local/codeql/queries/cpp/ql/examples)
codeql-cpp-tests (/home/greenpau/.local/codeql/queries/cpp/ql/test)
codeql-cpp-upgrades (/home/greenpau/.local/codeql/queries/cpp/upgrades)
codeql-csharp (/home/greenpau/.local/codeql/queries/csharp/ql/src)
codeql-csharp-examples (/home/greenpau/.local/codeql/queries/csharp/ql/examples)
codeql-csharp-tests (/home/greenpau/.local/codeql/queries/csharp/ql/test)
codeql-csharp-upgrades (/home/greenpau/.local/codeql/queries/csharp/upgrades)
codeql-go (/home/greenpau/.local/codeql/queries-go/ql/src)
codeql-go-examples (/home/greenpau/.local/codeql/queries-go/ql/examples)
codeql-go-tests (/home/greenpau/.local/codeql/queries-go/ql/test)
codeql-go-upgrades (/home/greenpau/.local/codeql/queries-go/upgrades)
codeql-java (/home/greenpau/.local/codeql/queries/java/ql/src)
codeql-java-examples (/home/greenpau/.local/codeql/queries/java/ql/examples)
codeql-java-tests (/home/greenpau/.local/codeql/queries/java/ql/test)
codeql-java-upgrades (/home/greenpau/.local/codeql/queries/java/upgrades)
codeql-javascript (/home/greenpau/.local/codeql/queries/javascript/ql/src)
codeql-javascript-examples (/home/greenpau/.local/codeql/queries/javascript/ql/examples)
codeql-javascript-tests (/home/greenpau/.local/codeql/queries/javascript/ql/test)
codeql-javascript-upgrades (/home/greenpau/.local/codeql/queries/javascript/upgrades)
codeql-python (/home/greenpau/.local/codeql/queries/python/ql/src)
codeql-python-examples (/home/greenpau/.local/codeql/queries/python/ql/examples)
codeql-python-tests (/home/greenpau/.local/codeql/queries/python/ql/test)
codeql-python-upgrades (/home/greenpau/.local/codeql/queries/python/upgrades)
codeql-suite-helpers (/home/greenpau/.local/codeql/queries/misc/suite-helpers)
legacy-libraries-cpp (/home/greenpau/.local/codeql/queries/misc/legacy-support/cpp)
legacy-libraries-csharp (/home/greenpau/.local/codeql/queries/misc/legacy-support/csharp)
legacy-libraries-go (/home/greenpau/.local/codeql/queries-go/ql/config/legacy-support)
legacy-libraries-java (/home/greenpau/.local/codeql/queries/misc/legacy-support/java)
legacy-libraries-javascript (/home/greenpau/.local/codeql/queries/misc/legacy-support/javascript)
legacy-libraries-python (/home/greenpau/.local/codeql/queries/misc/legacy-support/python)
legacy-upgrades (/home/greenpau/.local/codeql/codeql/legacy-upgrades)

cpp (/home/greenpau/.local/codeql/codeql/cpp)
csharp (/home/greenpau/.local/codeql/codeql/csharp)
csv (/home/greenpau/.local/codeql/codeql/csv)
go (/home/greenpau/.local/codeql/codeql/go)
html (/home/greenpau/.local/codeql/codeql/html)
java (/home/greenpau/.local/codeql/codeql/java)
javascript (/home/greenpau/.local/codeql/codeql/javascript)
properties (/home/greenpau/.local/codeql/codeql/properties)
python (/home/greenpau/.local/codeql/codeql/python)
ruby (/home/greenpau/.local/codeql/codeql/ruby)
xml (/home/greenpau/.local/codeql/codeql/xml)
@greenpau greenpau added the question Further information is requested label Apr 16, 2022
@aeisenberg
Copy link
Contributor

How did you create this database? Is it through the same CLI version that you are running the queries with? If not, do you know which cli version created the database?

@aeisenberg
Copy link
Contributor

Also, if you're using a checkout of the go queries please make sure they are up to date.

@greenpau
Copy link
Author

@aeisenberg , here is the process

Installation

First, install CodeQL:

export CODEQL_BIN_VERSION=2.8.5
mkdir -p $HOME/.local/tmp/codeql/src
mkdir -p $HOME/.local/codeql
rm -rf $HOME/.local/codeql/codeql
cd  $HOME/.local/tmp/codeql/src
curl -s -L -O https://github.com/github/codeql-cli-binaries/releases/download/v${CODEQL_BIN_VERSION}/codeql-linux64.zip && \
 unzip codeql-linux64.zip -d $HOME/.local/codeql
rm -rf codeql-linux64.zip

Add CodeQL path to ~/.bash_profile:

PATH=$HOME/.local/codeql/codeql:$PATH

Next, download queries:

export CODEQL_VERSION=1.27.0
cd $HOME/.local/codeql
git clone -b v${CODEQL_VERSION} --depth=1 https://github.com/github/codeql.git queries
git clone -b v${CODEQL_VERSION} --depth=1 https://github.com/github/codeql-go.git queries-go

Run the following command to see supported languages and language packs:

codeql resolve languages
codeql resolve qlpacks

Building Database

Next, create CodeQL database:

mkdir -p $HOME/.local/codeql/databases
cd $HOME/.local/codeql/databases
codeql database create \
  --language="go" \
  --source-root="${GOPATH}/src/github.com/greenpau/go-authcrunch" \
  -- ./go-authcrunch

The process runs and creates go-authcrunch/codeql-database.yml and other
files:

---
sourceLocationPrefix: "/home/greenpau/dev/go/src/github.com/greenpau/go-authcrunch"
baselineLinesOfCode: 68565
unicodeNewlines: false
columnKind: "utf8"
primaryLanguage: "go"
creationMetadata:
  sha: "6eac58e9e03a918ae09d4c0341acc08295944a7a"
  cliVersion: "2.8.5"
  creationTime: "2022-04-16T20:28:12.625549646Z"

@aeisenberg
Copy link
Contributor

I'm not actually at my computer now, so I can't check for sure. That branch name looks suspicious. Can you try checking out main instead? Or the tag corresponding to the CLI version you are using? 2.8.5

@greenpau
Copy link
Author

Can you try checking out main instead?

@aeisenberg , main for the CLI or queries?

@greenpau
Copy link
Author

@aeisenberg , issue solved. Followed advice from #7193

@greenpau
Copy link
Author

@aeisenberg , actually, let me reopen it, because I think there is a bug with the release 1.27.0.

The release is missing the scripts/install-deps.sh file.

$ ls scripts/
qhelp-to-markdown.sh

@aeisenberg
Copy link
Contributor

Hmmm...that's interesting. It looks like that file was never ported to the lgtm branch. I'll create a new issue for this in the appropriate repo. Thanks for reporting.

@aeisenberg
Copy link
Contributor

My mistake. The 1.27.0 branch is over a year old and predates the creation of the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants