简体   繁体   中英

Cannot determine Elasticsearch version from [elasticsearch --version] or [elasticsearch -v]: shift: can't shift that many

I am running elasticsearch inside a docker container. Dockerfile for the image looks like this:

# Dockerfile.ruby-2.4.1-elasticsearch-1.4.4
FROM ruby:2.4.1

# Install Java 8
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \
  echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \
  apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 && \
  apt-get update && \
  echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
  apt-get install -y oracle-java8-installer && \
  apt-get clean

# Download and unpack elasticsearch 1.4.4
RUN wget -q -O elasticsearch-1.4.4.tar.gz https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.4.4.tar.gz && \
  tar -xzf elasticsearch-1.4.4.tar.gz && \
  mv elasticsearch-1.4.4 $HOME/.elasticsearch && \
  ln -s $HOME/.elasticsearch/bin/elasticsearch /usr/local/bin/elasticsearch && \
  mkdir -p /usr/local/share/elasticsearch/ && \
  cp $HOME/.elasticsearch/bin/elasticsearch.in.sh /usr/local/share/elasticsearch/ && \
  rm elasticsearch-1.4.4.tar.gz

When I build it

docker build - < .gitlab-ci/Dockerfile.ruby-2.4.1-elasticsearch-1.4.4 -t hirurg103/ruby-2.4.1-elasticsearch-1.4.4

and start an interactive bash session

docker run -i -t hirurg103/ruby-2.4.1-elasticsearch-1.4.4 bash

and run elasticsearch --version inside the container I get

/usr/local/bin/elasticsearch: 168: shift: can't shift that many

The elasticsearch bin script on the line 168 looks the following way:

...
# Parse any long getopt options and put them into properties before calling getopt below
# Be dash compatible to make sure running under ubuntu works
ARGV=""
while [ $# -gt 0 ]
do
    case $1 in
      --*=*) properties="$properties -Des.${1#--}"
           shift 1
           ;;
      --*) properties="$properties -Des.${1#--}=$2"
           shift 2
           ;;
      *) ARGV="$ARGV $1" ; shift
    esac
done
...

Actual problem happens when I start my rspec tests and they fail with

/usr/local/bin/elasticsearch: 168: shift: can't shift that many
rake aborted!
Cannot determine Elasticsearch version from [elasticsearch --version] or [elasticsearch -v]

elasticsearch --version is being called from elasticsearch-extensions ruby gem

What is wrong with this script? How can I fix this error?

BTW on my local machine Mac OS 10.14.1 Mojave and zsh 5.6.2 tests run smoothly

For now I was able to resolve this error by specifying the elasticsearch version directly when initializing Elasticsearch::Extensions::Test::Cluster :

require 'elasticsearch/extensions/test/cluster'
Elasticsearch::Extensions::Test::Cluster.start(
  port: 9250,
  version: '1.0'
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM