6

I have a fresh Macbook Air with M1 processor

Following official guide https://www.elastic.co/guide/en/elasticsearch/reference/current/brew.html I've tried to install elasticsearch 7 with:

brew tap elastic/tap
brew install elastic/tap/elasticsearch-full

once I try to start it with $ elasticsearch I get this error:

/opt/homebrew/Cellar/elasticsearch-full/7.16.2/libexec/bin/elasticsearch-env: line 83: /opt/homebrew/Cellar/elasticsearch-full/7.16.2/libexec/jdk.app/Contents/Home/bin/java: Bad CPU type in executable

If I try to start the service with brew services start elastic/tap/elasticsearch-full It will fails and I'll get same error in log file /opt/homebrew/var/log/elasticsearch.log

/opt/homebrew/Cellar/elasticsearch-full/7.16.2/libexec/bin/elasticsearch-env: line 83: /opt/homebrew/Cellar/elasticsearch-full/7.16.2/libexec/jdk.app/Contents/Home/bin/java: Bad CPU type in executable

Once I open the file (elasticsearch-env) that causes the issue line 83 reads:

# check the Java version
"$JAVA" "$XSHARE" -cp "$ES_CLASSPATH" org.elasticsearch.tools.java_version_checker.JavaVersionChecker

If I try to execute

/opt/homebrew/Cellar/elasticsearch-full/7.16.2/libexec/jdk.app/Contents/Home/bin/java

I get the error

 Bad CPU type in executable

So it seems a bad Java architecture was installed during the elasticsearch-full brew instalation (maybe instead of M1 it's x84 or something ?). This is fresh new Macbook bought couple of hours ago. Elasticsearch was first thing I've tried to brew install on it (so no prior Java application installed)

Anyone knows how to solve this pretty please ?

2 Answers 2

8

You can also fix this by installing Rosetta 2 on your ARM Mac: softwareupdate --install-rosetta.

Apparently brew still installs the 64 bit version of elasticsearch.

2

Ok the issue was that I needed to install the Java JDK separately.

I've just installed Java OSX ARM DMG and then ES was working

As long as $ java -version don't throw you an error this error will not appear

1
  • also in order to change Memory consumption for Elasticsearch I recommend checking blog.eq8.eu/til/… By defaulth ES consume a lot of memory Dec 23, 2021 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.