srianoop
srianoop

Reputation: 51

Unable to generate native image using GraalVM

I was trying to create a custom runtime Lambda using quarkus and GraalVM and in that process(https://quarkus.io/guides/amazon-lambda), I was trying to build a native-image for the Gradle application. I have GraalVM(20.2.0) and native-image(20.2.0) installed on my windows machine along with the JAVA 11 and Docker. When i run the command to generate the native image I was getting this error. The command which i have used is gradlew clean build -Dquarkus.package.type=native -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:20.2.0-java11 -Dquarkus.native.container-build=true -Dquarkus.native.enable-http-url-handler=true

error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/images/create?fromImage=quay.io%2Fquarkus%2Fubi-quarkus-native-image&tag=20.2.0-java11: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running. Unable to get GraalVM version from the native-image binary. docker: error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/containers/create: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running See 'docker run --help'.

Task :quarkusBuild FAILED

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':quarkusBuild'. io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:307) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936) at io.quarkus.builder.BuildContext.run(BuildContext.java:277) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) at java.base/java.lang.Thread.run(Thread.java:834) at org.jboss.threads.JBossThread.run(JBossThread.java:479) Caused by: java.lang.RuntimeException: Image generation failed. Exit code: 127 at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:520) at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:276)

Can anyone help me with this issue.Thanks.

Upvotes: 3

Views: 9874

Answers (3)

Rohit Rajan
Rohit Rajan

Reputation: 1

For windows you need to install : https://aka.ms/vs/15/release/vs_buildtools.exe

and run the command : ".\mvnw package -P native" with your respective repo from your Visual studio.

steps : https://quarkus.io/guides/building-native-image

Use a 64-bit hosted developer command prompt : https://learn.microsoft.com/en-us/cpp/build/how-to-enable-a-64-bit-visual-cpp-toolset-on-the-command-line?view=msvc-170#use-a-64-bit-hosted-developer-command-prompt-shortcut

Upvotes: 0

king pong
king pong

Reputation: 327

I faced more or less the same issue with maven package in Windows:

mvn clean package -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel:21.2-java11

(...)

error during connect: Post "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/v1.24/images/create?fromImage=quay.io%2Fquarkus%2Fubi-quarkus-native-image&tag=21.2-jav
a11": open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified.

Solution: I've checked status of Docker daemon (Docker Desktop in Windows) and it was simply not running (probably because of lack of memory). I've restarted Docker, tried again the maven package and the docker pull worked as expected.

Upvotes: 4

Taufik Pirjade
Taufik Pirjade

Reputation: 440

Navigate to Docker installation and Try following command.

DockerCli.exe -SwitchDeamon

It will switch your container from windows to Linux and if there are no installations are there to support the switch it will throw you the error the along with link. please go through the link and complete the installation.

Upvotes: 0

Related Questions