The Wayback Machine - https://web.archive.org/web/20201110083148/https://github.com/github/codeql-cli-binaries/issues/2
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

Cannot access CodeQL environment variables in `database create --command` #2

Open
max-schaefer opened this issue Nov 19, 2019 · 1 comment
Labels
CLI

Comments

@max-schaefer
Copy link

@max-schaefer max-schaefer commented Nov 19, 2019

I would like to explicitly invoke the JavaScript autobuilder as part of codeql database create, with the ultimate goal of passing it some custom options. However, even invoking it without any options isn't as easy as I would have hoped, since I cannot figure out how to access CodeQL environment variables to specify the path to the autobuilder.

My first attempt of

codeql database create -l javascript --command '${CODEQL_EXTRACTOR_JAVASCRIPT_ROOT}/tools/autobuild.sh /path/to/database

was met with

A fatal error occurred: Failed to expand '${CODEQL_EXTRACTOR_JAVASCRIPT_ROOT}/tools/autobuild.sh' as an argument list.
(eventual cause: UserError "Attempting to expand unknown variable: CODEQL_EXTRACTOR_JAVASCRIPT_ROOT, available variables are: []")

@lcartey suggested adding env. like so:

codeql database create -l javascript --command '${env.CODEQL_EXTRACTOR_JAVASCRIPT_ROOT}/tools/autobuild.sh' /path/to/database

but that resulted in

A fatal error occurred: Failed to expand '${env.CODEQL_EXTRACTOR_JAVASCRIPT_ROOT}/tools/autobuild.sh' as an argument list.
(eventual cause: UserError "Attempting to expand unknown variable: env.CODEQL_EXTRACTOR_JAVASCRIPT_ROOT, ava...")

I am pretty sure this is the right environment variable name, cf. here.

Specifying the full path to the autobuild script is, of course, possible, but annoying.

@hmakholm
Copy link
Contributor

@hmakholm hmakholm commented Nov 19, 2019

The expansion that fails seems to be the one that happens in line 90 of CreateCommand.java. It is part of codeql database create, whereas the specific environment variables are only being created inside the codeql database trace-command that create subsequently invokes.

It is not clear to me why database create wants to expand variables at that point at all -- I suspect it is for the side effect of splitting the command into words. (Arguably that would be better left to the shell, keeping each command as a single string the entire way through and passing it to sh -c when we're ready to launch it).

@adityasharad adityasharad added the CLI label Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.