ES 7.4.0 and SQL CLI Script :: Environment Variable Issue?

Hi ELK Sensei (s),

I recently upgraded to Elasticsearch 7.4.0 because I want to take advantage of the SQL-like queries. But I’m hitting issues with the CLI interface script.

First off: I’m on an Ubuntu box, 16.04.4. My ES is the Docker variety; my version of Docker is 17.09.0-ce, build afdb6d4. My instance of Elasticsearch is running smoothly, with data populating very nicely.

Okay, I went to run the “elasticsearch-sql-cli” script, and here’s what happened:

[root@1234567890ab bin]# pwd
[root@1234567890ab bin]#
[root@1234567890ab bin]# ./elasticsearch-sql-cli https://elastic@
./elasticsearch-sql-cli: line 9: ./x-pack-env: No such file or directory
[root@1234567890ab bin]#

Weird thing is, the “x-pack-env” file IS in this directory:

[root@1234567890ab bin]# pwd
[root@1234567890ab bin]#
[root@1234567890ab bin]# ls -l *x-pack-env*
-rwxr-xr-x 1 elasticsearch root 346 Sep 27 08:40 x-pack-env
 [root@1234567890ab bin]#

When I look inside that file, here’s what I see:

[root@1234567890ab bin]# more x-pack-env
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# include x-pack-core jars in classpath
[root@1234567890ab bin]#

And just to be complete, here’s the “elasticsearch-sql-cli” script:

[root@1234567890ab bin]# more ./elasticsearch-sql-cli
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
source "`dirname "$0"`"/elasticsearch-env
source "`dirname "$0"`"/x-pack-env
CLI_JAR=$(ls $ES_HOME/bin/elasticsearch-sql-cli-*.jar)
exec \
"$JAVA" \
-jar "$CLI_JAR" \
[root@1234567890ab bin]#

So forgive me, but it seems like this might be an environment variable issue? The “elasticsearch-sql-cli” is in the same directory as “x-pack-env”, but “elasticsearch-sql-cli” doesn’t see it because its looking in "dirname "$0"`"/x-pack-env." And I don’t see that env variable set within the Docker container:

[root@1234567890ab bin]# printenv
[root@1234567890ab bin]#

(This seems like it may also be a problem with the “x-pack-env” script too, as that guy needs $ES_CLASSPATH, $ES_CLASSPATH, and $ES_HOME… which don’t seem to be set, either.)

A commented-out line in "x-pack-env" says: "include x-pack-core jars in classpath" Does that mean I have to set the ENV manually?

Is there a fix for this, or am I doing something wrong? Thanks!

I'm guessing you need to specify the ES_HOME environmental variable within your docker container. As a workaround you can replace the "`dirname "$0"`" with the absolute path to the bin folder.

Thanks Matriv,

Yeah, I thought I might have to manually add the missing EnvVars too. Its nice to know that I'm on your wavelength.

Just to be clear, you are also proposing editing the elasticsearch-sql-cli script with that absolute pathname? I was reluctant to do that kind of surgery, but feel better about doing it if that's your recommendation.


Happy to help,

There is an open issue in this area:

Extremely useful! thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.