GoogleCloudPlatform/buildpacks

./gradlew: permission denied error when deployed from Windows but success when deploying from Mac

imAtulSharma opened this issue · 2 comments

I have a Spring Application to deploy on Cloud Run and here is the source code link for the reference: https://github.com/LavishSwarnkar/Spring-Hello-World-Kt

The think is when I try to deploy the application on windows then the build fails on google cloud but the same project is building successfully while deployed from Mac.

Here is the few error logs from the build via Windows (IntelliJ):

Step #1: ===> BUILDING
Step #1: [builder] Timer: Builder started at 2024-02-10T06:59:32Z
Step #1: [builder] === Java - Runtime (google.java.runtime@0.9.1) ===
Step #1: [builder] Using requested runtime feature version: 17
Step #1: [builder] 2024/02/10 06:59:32 [DEBUG] GET https://dl.google.com/runtimes/ubuntu2204/openjdk/version.json
Step #1: [builder] ***** CACHE MISS: "openjdk"
Step #1: [builder] Installing v17.0.10+7.
Step #1: [builder] 2024/02/10 06:59:32 [DEBUG] GET https://dl.google.com/runtimes/ubuntu2204/openjdk/openjdk-17.0.10_7.tar.gz
Step #1: [builder] === Java - Gradle (google.java.gradle@0.9.0) ===
Step #1: [builder] --------------------------------------------------------------------------------
Step #1: [builder] Running "./gradlew clean assemble -x test --build-cache --quiet"
Step #1: [builder] Done "./gradlew clean assemble -x test --build-cache --quiet" (709.993µs)
Step #1: [builder] --------------------------------------------------------------------------------
Step #1: [builder] failed to build: (error ID: 14f2a5b3):
Step #1: [builder] executing command "./gradlew clean assemble -x test --build-cache --quiet": fork/exec ./gradlew: permission denied
Step #1: [builder] --------------------------------------------------------------------------------
Step #1: [builder] Sorry your project couldn't be built.
Step #1: [builder] Our documentation explains ways to configure Buildpacks to better recognise your project:
Step #1: [builder] -> https://cloud.google.com/docs/buildpacks/overview
Step #1: [builder] If you think you've found an issue, please report it:
Step #1: [builder] -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new
Step #1: [builder] --------------------------------------------------------------------------------
Step #1: [builder] Timer: Builder ran for 3.761392794s and ended at 2024-02-10T06:59:36Z
Step #1: [builder] ERROR: failed to build: exit status 1
Step #1: ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 51
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/k8s-skaffold/pack" failed: step exited with non-zero status: 1

NOTE: The command which is failed due to permission is also executed successfully in just previous step as you can see in logs.

As I have gone through another issue for maven project #149 there I found a solution of Line Separator.

I have changed Line Separator setting from CRLF to LF in IntelliJ (Windows) and then deployed again but facing same error logs.

You can see in the following images about my Line Separator, and they are also recognized by Git VCS.

  1. https://github.com/GoogleCloudPlatform/buildpacks/assets/60613670/699144a3-c246-4f17-89f2-c644eb292a38
  2. https://github.com/GoogleCloudPlatform/buildpacks/assets/60613670/7f718611-ae22-4edf-95d2-cb2c21fb8252

NOTE: I have also tried a sample Maven Spring project but facing same error.

we actually have a helper to replace the windows line endings in the maven wrapper: https://github.com/GoogleCloudPlatform/buildpacks/blob/main/cmd/java/maven/main.go#L139

Maybe we need a similar call in the gradle wrapper.