title: Building native image using quarkus on a M1 Mac fails
body: <p>From my project's root directory, I issued the following command to create a native executable that will be specific to my operating system. <a href="https://quarkus.io/guides/maven-tooling#build-a-container-friendly-executable" rel="nofollow noreferrer">See the following guide for details</a></p>
  <pre><code>mvn package -Pnative -Dquarkus.native.container-build=true
  </code></pre>
  <p>and here is the output.</p>
  <pre><code>[INFO] Scanning for projects...
  [INFO]
  [INFO] ---------------------&lt; com.example:quarkus-spring &gt;---------------------
  [INFO] Building quarkus-spring 1.0-SNAPSHOT
  [INFO] --------------------------------[ jar ]---------------------------------
  [INFO]
  [INFO] --- quarkus-maven-plugin:1.13.7.Final:generate-code (default) @ quarkus-spring ---
  [INFO]
  [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ quarkus-spring ---
  [INFO] Using 'UTF-8' encoding to copy filtered resources.
  [INFO] Copying 1 resource
  [INFO]
  [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ quarkus-spring ---
  [INFO] Nothing to compile - all classes are up to date
  [INFO]
  [INFO] --- quarkus-maven-plugin:1.13.7.Final:generate-code-tests (default) @ quarkus-spring ---
  [INFO]
  [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ quarkus-spring ---
  [INFO] Using 'UTF-8' encoding to copy filtered resources.
  [INFO] Copying 0 resource
  [INFO]
  [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ quarkus-spring ---
  [INFO] Nothing to compile - all classes are up to date
  [INFO]
  [INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ quarkus-spring ---
  [INFO]
  [INFO] -------------------------------------------------------
  [INFO]  T E S T S
  [INFO] -------------------------------------------------------
  [INFO] Running com.example.controller.GreetingControllerTest
  2021-06-22 21:17:05,339 WARN  [io.qua.dat.dep.dev.DevServicesDatasourceProcessor] (build-10) Unable to determine a database type for default datasource
  2021-06-22 21:17:05,340 WARN  [io.qua.agr.dep.AgroalProcessor] (build-16) The Agroal dependency is present but no JDBC datasources have been defined.
  2021-06-22 21:17:06,080 INFO  [io.quarkus] (main) Quarkus 1.13.7.Final on JVM started in 1.004s. Listening on: http://localhost:8081
  2021-06-22 21:17:06,081 INFO  [io.quarkus] (main) Profile test activated.
  2021-06-22 21:17:06,081 INFO  [io.quarkus] (main) Installed features: [agroal, cdi, hibernate-orm, hibernate-orm-panache, mongodb-client, mutiny, narayana-jta, resteasy, smallrye-context-propagation, spring-boot-properties, spring-data-jpa, spring-data-rest, spring-di]
  [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.755 s - in com.example.controller.GreetingControllerTest
  2021-06-22 21:17:06,699 INFO  [io.quarkus] (main) Quarkus stopped in 0.020s
  [INFO]
  [INFO] Results:
  [INFO]
  [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
  [INFO]
  [INFO]
  [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ quarkus-spring ---
  [INFO]
  [INFO] --- quarkus-maven-plugin:1.13.7.Final:build (default) @ quarkus-spring ---
  [INFO] [org.jboss.threads] JBoss Threads version 3.2.0.Final
  [WARNING] [io.quarkus.agroal.deployment.AgroalProcessor] The Agroal dependency is present but no JDBC datasources have been defined.
  [INFO] [org.hibernate.Version] HHH000412: Hibernate ORM core version 5.4.29.Final
  [INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /Users/viswanath/projects/quarkus-spring/target/quarkus-spring-1.0-SNAPSHOT-native-image-source-jar/quarkus-spring-1.0-SNAPSHOT-runner.jar
  [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /Users/viswanath/projects/quarkus-spring/target/quarkus-spring-1.0-SNAPSHOT-native-image-source-jar/quarkus-spring-1.0-SNAPSHOT-runner.jar
  [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Using docker to run the native image builder
  [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Checking image status quay.io/quarkus/ubi-quarkus-native-image:21.0-java11
  21.0-java11: Pulling from quarkus/ubi-quarkus-native-image
  Digest: sha256:356624049da5f564e14acbaf167a341a01b332569db83e9967b1e72cfdf06653
  Status: Image is up to date for quay.io/quarkus/ubi-quarkus-native-image:21.0-java11
  quay.io/quarkus/ubi-quarkus-native-image:21.0-java11
  [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 21.0.0.2 (Java Version 11.0.10+8-jvmci-21.0-b06)
  [INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm -v /Users/viswanath/projects/quarkus-spring/target/quarkus-spring-1.0-SNAPSHOT-native-image-source-jar:/project:z quay.io/quarkus/ubi-quarkus-native-image:21.0-java11 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 -J-Duser.language=en -J-Duser.country=GB -J-Dfile.encoding=UTF-8 --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -jar quarkus-spring-1.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -J-Xmx8192m -H:-AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services --no-server -H:-UseServiceLoaderFeature -H:+StackTrace quarkus-spring-1.0-SNAPSHOT-runner
  WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
  ^C%
  </code></pre>
  <p><strong>Native image generation fails as the build just hangs.</strong></p>
  <hr />
  <p>I chose to install Graal VM on my host and opt for the non-container based approach as shown below.</p>
  <ul>
  <li><p>Install Graal VM on M1 Mac using the following command</p>
  <p>❯ brew install --cask graalvm/tap/graalvm-ce-lts-java11</p>
  </li>
  <li><p>Add Graal VM to JEnv managed versions of Java</p>
  <p>❯ jenv add /Library/Java/JavaVirtualMachines/graalvm-ce-lts-java11-20.3.1/Contents/Home
  graalvm64-11.0.10 added</p>
  </li>
  <li><p>For the project, set Graal VM's Java 11. From the project's directory, issue the following command</p>
  <p>❯ jenv local graalvm64-11.0.10</p>
  </li>
  <li><p>Set GRAALVM_HOME environment variable to the GraalVM installation directory. Add the following to ~/.zshrc</p>
  <p>❯ export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-lts-java11-20.3.1/Contents/Home</p>
  </li>
  </ul>
  <p>and reload changes made to .zshrc by issuing the command</p>
  <pre><code>❯ source ~/.zshrc
  </code></pre>
  <ul>
  <li><p>Install the native-image tool using the following command. Some previous releases of GraalVM included the native-image tool by default. This is no longer the case; it must be installed as a second step after GraalVM itself is installed.</p>
  <p>❯ ${GRAALVM_HOME}/bin/gu install native-image</p>
  </li>
  <li><p>Install binutils and add it to the path</p>
  <p>❯ brew install binutils</p>
  <p>❯ echo 'export PATH=&quot;/opt/homebrew/opt/binutils/bin:$PATH&quot;' &gt;&gt; ~/.zshrc
  ❯ source ~/.zshrc</p>
  </li>
  <li><p>Create a native executable using the following caommand from project's root directory</p>
  <p>❯ mvn clean install -Pnative -Dnative-image.docker-build=true -Dquarkus.native.native-image-xmx=4g</p>
  </li>
  </ul>
  <p>Finally when I ran the native image, it failed.</p>
  <pre><code>❯ ~/projects/quarkus-spring/target ./quarkus-spring-1.0-SNAPSHOT-runner                                      
  [1]    11638 killed     ./quarkus-spring-1.0-SNAPSHOT-runner
  </code></pre>
  <p>Any help?</p>