Elasticsearch 7 SQL CLI : ./x-pack-env: No such file or directory error

443 views Asked by At

I have started working on Elasticsearch 7 and trying to start the elasticsearch-sql-cli using the following command:

~/Documents/backups/es7/bin$ ./elasticsearch-sql-cli

But it is not started and getting the following error:

./elasticsearch-sql-cli: line 9: ./x-pack-env: No such file or directory

I opened up the ./x-pack-env file and found that it is using ES_HOME environment variable. Here is the content for the x-pack-env file:

#!/bin/bash

# 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
ES_CLASSPATH="$ES_CLASSPATH:$ES_HOME/modules/x-pack-core/*"

So i added up the environment variable in bash_profile,

#ES
export ES_HOME=/Users/Documents/backups/es7
export PATH=$ES_HOME/bin:$PATH

But still i am getting the same error for

./elasticsearch-sql-cli: line 9: ./x-pack-env: No such file or directory

Please suggest how to solve this issue.

1

There are 1 answers

0
macatak On

Had the same issue in 7.4.2 and managed to fix it. That x-pack-env file is in /usr/share/elasticsearch/bin/ (least in Linux). I opened the elasticsearch-sql-cli file in an editor commented out the original line and replaced it:

#source "`dirname "$0"`"/x-pack-env
source /usr/share/elasticsearch/bin/x-pack-env

Also, as an FYI, it wants to see Elasticsearch running on localhost and will fail if it's not. I run mine on VM's and use the IP. To get it to start, run something like this but change the URI to whatever your Elasticsearch is running on. Command is assuming your in /usr/share/elasticsearch/bin.

./elasticsearch-sql-cli uri=http://10.10.12.22:9200/

Imagine this will work on Windows if you change the path formatting and paths but not sure.