Print nice error in bin/elasticsearch if user needs to run maven

Before, people that cloned the repo and expected to be able to run
bin/elasticsearch would be met with an awful shell error: the shell
interprets Maven variables like ${project.build.finalName} as shell
variables yet can't handle names of the form ${x.y}. This commit
explicitly checks to make sure that Maven has done its substitutions
before continuing; if Maven hasn't been run, it gives a helpful error
message.

Fixes #2954.
This commit is contained in:
Diego Ongaro 2013-12-10 18:12:45 -08:00 committed by Alexander Reelsen
parent 976bdd6a26
commit a4814c2f69
1 changed files with 14 additions and 0 deletions

View File

@ -46,6 +46,20 @@
# Be aware that you will be entirely responsible for populating the needed
# environment variables.
# Maven will replace the project.name with elasticsearch below. If that
# hasn't been done, we assume that this is not a packaged version and the
# user has forgotten to run Maven to create a package.
IS_PACKAGED_VERSION='${project.name}'
if [ "$IS_PACKAGED_VERSION" != "elasticsearch" ]; then
cat >&2 << EOF
Error: You must build the project with Maven or download a pre-built package
before you can run Elasticsearch. See 'Building from Source' in README.textile
or visit http://www.elasticsearch.org/download to get a pre-built package.
EOF
exit 1
fi
CDPATH=""
SCRIPT="$0"