Skip to content

CLI tools in linux only work from within $ES_HOME #40889

@jkakavas

Description

@jkakavas

In https://github.com/elastic/elasticsearch/blob/master/distribution/src/bin/elasticsearch-cli,

when we

source "`dirname "$0"`"/elasticsearch-env

we cd in $ES_HOME changing the pwd. However, the dirname commands in the following

for additional_source in "${additional_sources[@]}"
do
  source "`dirname "$0"`"/$additional_source
done

will have an output that is always relevant to the current dir from where the user ran the cli command.

The combination of these two mean, that the source command will try to source a file, the path of which will be the concatenation of $ES_HOME and the dir from where the user ran the cli command. This will only work when the user runs the command from $ES_HOME. Example output from @pheyos who raised this:

robert@elastic-ro:~/es_versions/700_bc1/elasticsearch-7.0.0/bin$ ./elasticsearch-setup-passwords interactive
./elasticsearch-cli: line 10: ./x-pack-env: No such file or directory

./elasticsearch-cli: line 10: ./x-pack-env: No such file or directory is because the pwd at that time is $ES_HOME and not $ES_HOME/bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions