Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

./gradlew: not found local cluster deployment #1347

Closed
anasj25 opened this issue Dec 2, 2022 · 10 comments · Fixed by #1806
Closed

./gradlew: not found local cluster deployment #1347

anasj25 opened this issue Dec 2, 2022 · 10 comments · Fixed by #1806
Assignees
Labels
needs more info This issue needs more information from the customer to proceed. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@anasj25
Copy link

anasj25 commented Dec 2, 2022

Step 4/18 : COPY gradle gradle
---> ca2a614ce472
Step 5/18 : RUN chmod +x gradlew
---> Running in 4cfbc82c2da9
Removing intermediate container 4cfbc82c2da9
---> 4ab32a37dc28
Step 6/18 : RUN ./gradlew downloadRepos
---> Running in 374228cb6f66
/bin/sh: 1: ./gradlew: not found
The command '/bin/sh -c ./gradlew downloadRepos' returned a non-zero code: 127

@mathieu-benoit mathieu-benoit added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. needs more info This issue needs more information from the customer to proceed. labels Dec 2, 2022
@mathieu-benoit
Copy link
Contributor

mathieu-benoit commented Dec 2, 2022

Thanks @anasj25 for reporting this issue!

Just to confirm, could you clarify which command you are running please? For example, is it skaffold run or docker build?

Are you on Linux, MacOS or Windows?

I just tested cd src/adservice && docker build -t adservice . and it's working successfully without the error/issue you are facing (also, our Continuous Integration system is running skaffold run against any PR and merge in main branch, with no issues):

Step 4/18 : COPY gradle gradle
 ---> 6a53b84138b6
Step 5/18 : RUN chmod +x gradlew
 ---> Running in 7c0aa69d8b5c
Removing intermediate container 7c0aa69d8b5c
 ---> 5514d4121c79
Step 6/18 : RUN ./gradlew downloadRepos
 ---> Running in 78bbabedbb48
Downloading https://services.gradle.org/distributions/gradle-7.6-bin.zip
...........10%............20%...........30%............40%............50%...........60%............70%............80%...........90%............100%

Welcome to Gradle 7.6!

Also, could you confirm that you have the latest version of Online Boutique?

Thanks for providing more context and information to help us diagnosing this issue.

Note: JFYI: I see that we had in the past couple of issues related to this one with Minikube disk allocation or because on Windows: https://github.com/GoogleCloudPlatform/microservices-demo/issues?q=is%3Aissue+gradlew+is%3Aclosed.

@anasj25
Copy link
Author

anasj25 commented Dec 5, 2022

Hi Mathieu,
I am on windows and I ran the skaffold run command. And yes I cloned the latest Online Boutique repo on my PC.

@mathieu-benoit mathieu-benoit removed the needs more info This issue needs more information from the customer to proceed. label Dec 5, 2022
@minherz minherz added the priority: p2 Moderately-important priority. Fix may not be included in next release. label Dec 14, 2022
@minherz minherz assigned mathieu-benoit and unassigned anasj25 Dec 14, 2022
@NimJay
Copy link
Collaborator

NimJay commented Apr 18, 2023

Hey @anasj25,

  • Sorry for the extremely late response!
  • Thanks for providing additional info. :)
  • The error message is similar to error message seen in issue 1434.
/bin/sh: 1: ./gradlew: not found
git clone https://github.com/GoogleCloudPlatform/microservices-demo.git --config core.autocrlf=true
  • Actually, a plain old git clone https://github.com/GoogleCloudPlatform/microservices-demo.git should also work because of Add .gitattributes to convert "CR + LF" to "LF" #1688.
  • This issue seems related to the following discrepancy:
    • Windows uses CR + LF as a new line character
    • Linux uses LF as a new line character

@minherz minherz assigned anasj25 and unassigned mathieu-benoit May 23, 2023
@minherz minherz added the needs more info This issue needs more information from the customer to proceed. label May 23, 2023
@minherz
Copy link
Contributor

minherz commented May 23, 2023

@anasj25 can you please confirm that the issue is still reproducible following @NimJay's comment?

@marcghanime
Copy link

Hello @minherz & @NimJay,

i have the same problem on Windows 11 with Minkube

Error with skaffold run:

Building [adservice]...
Target platforms: [linux/amd64]
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
            environment-variable.

Sending build context to Docker daemon  117.2kB
Step 1/19 : FROM eclipse-temurin:19@sha256:f3fbf1ad599d4b5dbdd7ceb55708d10cb9fafb08e094ef91e92aa63b520a232e as builder
 ---> f546b418bb3a
Step 2/19 : WORKDIR /app
 ---> Using cache
 ---> de3fef9c1bce
Step 3/19 : COPY ["build.gradle", "gradlew", "./"]
 ---> Using cache
 ---> 29e208f43c2a
Step 4/19 : COPY gradle gradle
 ---> Using cache
 ---> d8420a3827c0
Step 5/19 : RUN chmod +x gradlew
 ---> Using cache
 ---> 5cc3fdf9796c
Step 6/19 : RUN ./gradlew downloadRepos
 ---> Running in 05a20dc9e5d6
/bin/sh: 1: ./gradlew: not found
The command '/bin/sh -c ./gradlew downloadRepos' returned a non-zero code: 127
build [adservice] failed: exit status 127. Docker build ran into internal error. Please retry.
If this keeps happening, please open an issue..

Error with docker build:

 => [without-grpc-health-probe-bin 3/5] RUN mkdir -p /opt/cprof &&     wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent_alpine.tar.gz     | tar x  2.1s
 => [without-grpc-health-probe-bin 4/5] WORKDIR /app                                                                                                                                        0.0s 
 => [builder 2/9] WORKDIR /app                                                                                                                                                              0.3s 
 => [builder 3/9] COPY [build.gradle, gradlew, ./]                                                                                                                                          0.0s 
 => [builder 4/9] COPY gradle gradle                                                                                                                                                        0.0s 
 => [builder 5/9] RUN chmod +x gradlew                                                                                                                                                      0.3s 
 => ERROR [builder 6/9] RUN ./gradlew downloadRepos                                                                                                                                         0.6s 
------
 > [builder 6/9] RUN ./gradlew downloadRepos:
#0 0.543 /bin/sh: 1: ./gradlew: not found
------
Dockerfile:22
--------------------
  20 |     COPY gradle gradle
  21 |     RUN chmod +x gradlew
  22 | >>> RUN ./gradlew downloadRepos
  23 |
  24 |     COPY . .
--------------------
ERROR: failed to solve: process "/bin/sh -c ./gradlew downloadRepos" did not complete successfully: exit code: 127

@marcghanime
Copy link

Hello again,

I was able to fix it by going into VS Code and manually setting the end of line sequence as LF instead of CRLF for the following files:

src\adservice\Dockerfile
src\adservice\gradlew
src\adservice\gradlew.bat

I'm not sure if all 3 are required to fix the bug but I tried these 3 together at first and it worked.
Cloning the latest version with this workaround did not work for me for some reason.

You can change the end of line sequence in VS Code by opening the Command Palette (Ctrl+Shift+P) and selecting Change End of Line Sequence and setting it to LF.

@minherz
Copy link
Contributor

minherz commented May 26, 2023

@NimJay , can you please have a look.

@minherz minherz assigned NimJay and unassigned anasj25 May 26, 2023
@NimJay
Copy link
Collaborator

NimJay commented May 29, 2023

@marcghanime thank you for not only reporting your issue, but also finding and sharing a fix! 👏

I have created pull-request 1806 to fix the issue (i.e., convert existing CRLF files in this repo to LF).

If possible, could you please:

git checkout nimjay-lf
cd src/adservice
docker build --no-cache . -t my-adservice-test

and let me know if you are able to successfully build the adservice using the nimjay-lf branch, on Windows.
Command to delete the image:

docker image rm my-adservice-test

@marcghanime
Copy link

Hey @NimJay,

I have tried to build the service with your changes but it still fails. I also found out that only the src\adservice\gradlew file needs to be changed to LF, keeping the src\adservice\Dockerfile and src\adservice\gradlew.bat files as they come also leads to successful builds. I also noticed that in the pull request the files changed do not include the src\adservice\gradlew file which (at least on my machine) is the only file that needs to be changed to LF.

It also might be that git on windows automatically changes all the files to CRLF as explained here.

@NimJay
Copy link
Collaborator

NimJay commented May 31, 2023

Thanks once again, @marcghanime! That info helps.

  • I've updated the the fix in pull-request 1806.
    • I changed the .gitattributes line from * text=auto to * text=auto eol=lf.
    • This will force Windows to use LF locally when you git clone (according to this article and my personal testing on Windows).
  • I have tested pull-request 1806 on a Windows machine using:
git clone --single-branch --branch nimjay-lf https://github.com/GoogleCloudPlatform/microservices-demo.git
cd .\microservices-demo\
git ls-files --eol | findstr gradle
  • In the output, I saw that my local files were using LF:
i/lf    w/lf    attr/text=auto eol=lf   src/adservice/build.gradle
i/-text w/-text attr/text=auto eol=lf   src/adservice/gradle/wrapper/gradle-wrapper.jar
i/lf    w/lf    attr/text=auto eol=lf   src/adservice/gradle/wrapper/gradle-wrapper.properties
i/lf    w/lf    attr/text=auto eol=lf   src/adservice/gradlew
i/lf    w/lf    attr/text=auto eol=lf   src/adservice/gradlew.bat
i/lf    w/lf    attr/text=auto eol=lf   src/adservice/settings.gradle
  • I have also tested skaffold run --module=app on a local kind cluster (on a Window machine). Online Boutique worked.
  • Unfortunately, the fix from pull-request 1806 does not work for existing/old clones of this repo. To apply the fix, you may need to additionally run (according to this article):
git rm --cached -r .
git reset --hard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info This issue needs more information from the customer to proceed. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants