exist icon indicating copy to clipboard operation
exist copied to clipboard

Build exist-db on an arm Mac (M1)

Open line-o opened this issue 3 years ago • 6 comments

This is an attempt of a step-by-step guide on how-to set-up a M1 Mac to build and run exist-db. Special thanks to @duncdrum for helping me get to this point 💯

Corrections, enhancements and other constructive feedback is very much welcome.

Prerequisites

You will need to have brew and git installed in order to follow the steps. We also assume that you did checkout this repository on your local machine.

First, if you tried to build exist-db before you should clean up any leftover artifacts:

  1. Remove downloaded artifacts in the maven repository
rm -rf ~/.m2/repository
  1. Go to your git working directory, where you checked out exist-db and remove any leftover target directories
git clean -dfX

Start here if your local machine is clean:

  1. Allow brew to install packages in different versions
    brew tap homebrew/cask-versions
    
  2. Install ARM optimised java8
    brew install zulu8
    
    • (OPTIONAL) Install jenv if you want to have several JDKs installed and switch between them
    brew install jenv
    
    • (OPTIONAL) Add jenv init to your bash, zsh or fish config
    source (jenv init -|psub) 
    
    • (OPTIONAL) Add zulu8 to jenv
    jenv add /opt/homebrew/Caskroom/zulu8/8.0.322,8.60.0.21-ca/
    
    • (OPTIONAL) Use java8 globally (as @duncdrum pointed out this could also be done per project)
    jenv global 1.8
    
  3. Install maven
    brew install maven
    
    • (OPTIONAL) If you installed jenv in the previous step, tell it to take care of maven
    jenv enable-plugin maven
    

Open a new terminal and make sure that:

  1. JAVA_HOME points to your zulu8 installation (or to jenv)
    echo $JAVA_HOME
    
    • (OPTIONAL) jenv is reporting three times OK
    ; jenv doctor
    
    [OK]	JAVA_HOME variable probably set by jenv PROMPT
    [OK]	Java binaries in path are jenv shims
    [OK]	Jenv is correctly loaded
    
  2. maven uses the correct JDK
    ; mvn -v
    
     Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
     Maven home: /opt/homebrew/Cellar/maven/3.8.5/libexec
     Java version: 1.8.0_322, vendor: Azul Systems, Inc., runtime: /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
     Default locale: en_DE, platform encoding: UTF-8
     OS name: "mac os x", version: "12.3", arch: "aarch64", family: "Mac"
    

Now you should be able to build exist-db

mvn clean package

The tests should all pass! But I saw some exceptions about log4j not being able to access or create log files for some extensions.

It took 7:07 minutes to package and test exist-db on my MacBook Pro, so when it works it works fine. Adding -T2C will shave off another 2 minutes and you will likely hear the fans spinning for the first time :)

line-o avatar Mar 24 '22 19:03 line-o

Thank you very much. Using the java8 for M1 may solve my issue with freezings while using exist a couple of minutes. Will definitely give it a try

StephanMa avatar Mar 24 '22 19:03 StephanMa

@StephanMa what JRE are you using, what version of exist? there should be no freezing with an ARM compatible JRE exist runs smoothly on M1

duncdrum avatar Mar 24 '22 21:03 duncdrum

I would point out the jenv is strongly recommended for devs who require multiple JRE/JDKs on their local machine, but its not necessary. When using jenv zulu8 doesn't have to be configured as global it can be project specific just for exist.

The requirements on M1 aren't that different from Intel machines. You need to have JAVA_HOME set, Java 8 and maven. The only difference is that on M1 it needs to be an ARM friendly Java 8, multiple vendors have that on offer. Installing maven via homebrew has a tendency to install openjdk17 (often non arm) but that's a quirk of homebrew.

duncdrum avatar Mar 24 '22 21:03 duncdrum

@duncdrum I reworked this issue to address your comments.

line-o avatar Mar 25 '22 14:03 line-o

@line-o as discussed on Slack I made some minor edits. I think that the jenv doctor report is a quirk of fish, on zsh (the default macOS shell) JAVA_HOME is handled properly by jenv.

duncdrum avatar Mar 28 '22 20:03 duncdrum

Two more findings: If you decided to go the jenv route

  • add jenv enable-plugin maven also to your shell init script
  • for ant to work also add jenv enable-plugin ant

line-o avatar Mar 30 '22 17:03 line-o